Macbook pro ejects every CD/DVD just after a few seconds
Try the following steps and I am sure it will be fixed.


Clean the SuperDrive’s slot with compressed gas/vacuum cleaner.
Reset the NVRAM/PRAM and SMC


Reset NVRAM and PRAM:
Shut down the computer. Holding down the Command (Apple), Option, P, and R and then hold the Power button simultaneously, 3 times and wait for 3 loud chimes.

Delete the Finder’s preference files

Some people have reported successfully fixing Optical CD/DVD Drive on Mac or SuperDrive issues by deleting the Finder’s preference files (don’t worry, the Finder will automatically make new ones). You’ll want to delete two files: “com.apple.finder.plist” and “com.apple.sidebarlists.plist”. Both of these files are located in Users > [Your User] > Library > Preferences.
Run Disk Utility and Repair Disk Permissions
Delete the following configuration file to create a fresh copy

~/Library/Caches (your local Library directory). 
System/Library/extensions.kextcache.
/System/Library/Extensions.mkext.
/System/Library/Caches/com.apple.kernelcaches (a directory).
/System/Library/Caches/com.apple.romextensions (a directory).
CD Info.cidb


Credits - http://coreyjmahler.com/2013/06/15/how-to-fix-a-macbook-pro-superdrive-which-continually-ejects-discs/