How do I trigger the build in Jenkins once the code is committed?
Below are the SVN version details.
Jenkins URL: "localhost:8080/job/TestProject/"
To have the build triggered immediately once the code is committed, you'll need to have something notifying Jenkins.
However you can configure your job to poll your SCM regularly (at my shop we poll our Mercurial repositories every 5 minutes) for new changes and build if there are new changes.
For this, in the Build Triggers section, you check the Poll SCM checkbox, and fill in a cron expression in the textarea. For polling every 5 minutes, we use
H/5 * * * *
Note that we used to use
*/5 * * * *
but replacing the left *
by the H
allows Jenkins to avoid polling for all projects at the same time (it will then poll every 5 minutes, but not necessarily at 0, 5, 10, etc. minutes.
One can also trigger builds remotely by checking Trigger builds remotely and specifying a token in the textbox. Then a simple contact from a script to the relevant URL will trigger the build.
JENKINS_URL/job/JOB_NAME/build?token=TOKEN_NAME
(This option might require some particular permissions to set up, or some particular global configuration, as it seems it's not available to OP.)
For the post-commit hook solution, see Jenkins' Subversion Plugin documentation, with the important parts below:
Jenkins can poll Subversion repositories for changes, and while this is reasonably efficient, this can only happen up to every once a minute, so you may still have to wait a full minute before Jenkins detects a change.
To reduce this delay, you can set up a post commit hook so the Subversion repository can notify Jenkins whenever a change is made to that repository. To do this, put the following script in your post-commit file (in the $REPOSITORY/hooks directory):
REPOS="$1" REV="$2" UUID=`svnlook uuid $REPOS` /usr/bin/wget \ --header "Content-Type:text/plain;charset=UTF-8" \ --post-data "`svnlook changed --revision $REV $REPOS`" \ --output-document "-" \ --timeout=2 \ http://server/subversion/${UUID}/notifyCommit?rev=$REV
(It is really recommended to read the full documentation for information related to the configuration or for a more robust script.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With