IntroductionFor CFMongoDB , I wanted to run all tests on a schedule, either when a source code change was detected on github, or every day. I didn't want to have Mongo running all the time -- just when the tests needed to run. Ideally, my CI process would start Mongo, run the tests, and stop Mongo when finished. Here's how I accomplished that. Installing MongoDB as a serviceIt was easiest for me to achieve this workflow by starting MongoDB as a Windows service because then I could simply use NET START and NET STOP commands rather than spinning up Mongod.exe and killing it. Installing mongod as a service is as simple as: How you will be able to run this service in Jenkins, but can't quite yetLong heading, I know. In Jenkins, configuring the "Build Steps" should look like this:
However, due to this bug , stopping the mongo service throws an error which will cause the Jenkins build to fail. And that won't do. How to use ANT to start and stop the MongoDB Windows ServiceFortunately, you can add ANT targets to start and stop these services which won't throw errors when start/stop fails, which is the behavior I need. build.xml Then, in the Jenkins config, I simply specify "startMongoService runtests stopMongoService" as the ANT targets to run. |
Navigate space |