For 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.
It 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:
Long 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.
Fortunately, 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.
Then, in the Jenkins config, I simply specify "startMongoService runtests stopMongoService" as the ANT targets to run.