0

I need some help in integrating protractor code with Jenkins. I am new to Jenkins so i am not sure if Jenkins or Cruise Control is right as currently we have builds in Cruise Control but we are okay to migrate to Jenkins if that is better. Can someone please help me with any tutorials to link my protractor task with Jenkins or Cruise Control? Currently we are using Gulp as a wrapper over Javascript code for execution. We are running it with command Gulp test --site folder name Should i just specify this command in Execute shell script option of Jenkins?

NewWorld
  • 764
  • 1
  • 10
  • 31

2 Answers2

1

Yes, running Protractor tests from any CI tool is not complicated

Step 1:Just configure your cruise control/Jenkins job with "Execute Shell" as build step Step 2: Depending on your choice of running tests .. create a bat file

echo Protractor Execution
Protractor protractor.conf.js // In case running with protractor
npm run --e2etests // In case running with npm run config in package.json
Gulp test --site folder name // In your case
echo Over and out.

Step 3: Point your job build step to trigger the batch file

AdityaReddy
  • 3,625
  • 12
  • 25
  • I tried using command /Users/akuchhal/Desktop/tests/file.bat in Execute Shell and also mentioned following in .bat file but it is not working. echo Protractor Execution Gulp test --site folder name echo Over and out. is there anything else i need to do. – NewWorld Sep 07 '16 at 15:21
  • Did you trigger the bat file directly and check if its working before triggering it from Jenkins? – AdityaReddy Sep 07 '16 at 15:31
  • No, it is not working. It says command not found.. Earlier it was throwing permission error and when i used sudo ./file.bat it says "Command not found" – NewWorld Sep 07 '16 at 15:38
  • Are you running it on local machine or Jenkins machine? Is node & its dependencies installed in the Jenkins machine? is gulp packages installed? Did it work on command line? if it worked .. bat file is not different .... – AdityaReddy Sep 07 '16 at 15:41
  • Command that i have in .bat file is "gulp test --site folder name" This is working fine when i run it in terminal – NewWorld Sep 07 '16 at 15:41
  • I am using it in local machine. Yes, node and everything is installed and this command is running fine in terminal – NewWorld Sep 07 '16 at 15:42
  • I am not sure if you mean 'cmd' when you say terminal. But which machine are you using? if windows .. can you confirm if you tried the same from cmd and if it worked? – AdityaReddy Sep 07 '16 at 15:48
  • I am using MAC terminal – NewWorld Sep 07 '16 at 15:49
  • oh .. things work different in mac w.r.t bat file and may be you need path settings . Just try providing the command directly in Jenkins instead of .bat file and check if its all good. If not .. may be you have to set path - http://stackoverflow.com/questions/24027551/gulp-command-not-found-error-after-installing-gulp – AdityaReddy Sep 07 '16 at 16:02
  • It is running now from Jenkins but getting an error Error: ENOENT: no such file or directory, open '.env' at Error (native) at Object.fs.openSync (fs.js:640:18) at Object.fs.readFileSync (fs.js:508:33) at Object.config (/Users/akuchhal/.jenkins/workspace/Demo/node_modules/dotenv/lib/main.js:30:37) at Object. (/Users/akuchhal/.jenkins/workspace/Demo/ProtractorConfig.js:2:19) at Function.Module._load (module.js:424:3) errno: -2, code: 'ENOENT', syscall: 'open', path: '.env' } – NewWorld Sep 07 '16 at 20:27
0

I got this one worked out. It is working fine when i enter protractor command in Jenkins directly. I am having some issues with gulp command in jenkins but i will open a seperate thread on that.

NewWorld
  • 764
  • 1
  • 10
  • 31