Reputation: 91
So I am using Ruby/Cucumber and Appium to run automated tests after each of our builds on our Jenkins server.
Essentially I have a job set up that runs our regression suite after every build that is successful. My problem comes in when my cucumber tests are running and a new build is successful.
At the moment Jenkins will start a new series of tests with the cucumber script, but won't force the old script to quit. This leads to all of my cucumber reports showing multiple false negatives. Is there a way to stipulate that Jenkins run a script that quits cucumber before starting a new set of tests?
Thanks a ton for any help you can give me. If you have any questions about how I have Jenkins set up specifically just ask and I'll give you the more intimate details.
Upvotes: 0
Views: 113
Reputation: 186
Technically Jenkins Job will wait for 1 instance of job to complete until it starts another one. So you dont have to worry about starting another build before first one finishes...
Now coming to your question how to kill old/existing test cases if a set of new ones want to start.
I would suggest to have a cleanup script run before your actual tests are triggered, your tests would be triggering using a rake or direct cucumber command, I am guessing. So before this happens, have a cleanup.sh
executed which will do the following:
1) Restart appium server.
2) Kill running ruby processes.
3) Kill running cucumber processes.
The script should look something like this:
kill -9 $(ps -ef | grep \[a]ppium | awk '{print $2}')
kill -9 $(ps -ef | grep \[r]uby | awk '{print $2}')
kill -9 $(ps -ef | grep \[c]ucumber | awk '{print $2}')
# restart appium again
appium &
Hope it helps!! Let me know in comments if you run into issues.. :)
Upvotes: 1