Wednesday, June 25, 2014

Trigger Jenkins build on SVN commit with push notification

The continuous integration server Hudson knows several ways to trigger a build. If you’d like Hudson to build your project when the source-base changes and you don’t want to let him poll your Subversion periodically let Subversion trigger the build upon commit. To do that, first, configure your job in Hudson (Job -> Configure -> Build Triggers) with “Trigger builds remotely (e.g., from scripts)” (”uDoo” is the job name, so replace it with your job name):


hudson_build_trigger


Second, configure a post-commit hook in your Subversion repository: In the repository directory of your Subversion-server, a directory hook exists. In this directory you may already have a file post-commit with 744 permissions. If not, a file post-commit.tmpl exists. In that case, copy the file and change the permissions:
$ cd path/to/your/repository/hook
$ cp post-commit.tmpl post-commit
$ chmod 744 post-commit
To trigger the build via Subversion, just put the following line at the end of the post-commit file.
wget -b http://HUDSON_URL/job/JOB_NAME/build?token=my_automated_build > /dev/null
That’s it.


This is cached version of this.
To trigger build with password-protected jenkins, you could check this great article.

No comments:

Post a Comment