What plugins and plugin features do I need to set in order to get my Jenkins job to trigger a build any time code is committed to an SVN project?
I have installed both the standard SVN plugin as well as the SVN tagging plugin, but I do not see any new features that allow trigger configuration.
You need to require only one plugin which is the Subversion plugin.
Then simply, go into Jenkins → job_name → Build Trigger section → (i) Trigger build remotely (i.e., from scripts) Authentication token: Token_name
Go to the SVN server's hooks directory, and then after fire the below commands:
cp post-commit.tmpl post-commit
chmod 777 post-commit
chown -R www-data:www-data post-commit
vi post-commit
Note: All lines should be commented Add the below line at last
Syntax (for Linux users):
Syntax (for Windows user):
You can use a post-commit hook.
Put the post-commit hook script in the
hooks
folder, create awget_folder
in your C:\ drive, and put thewget.exe
file in this folder. Add the following code in the file calledpost-commit.bat
where Test = name of the job
echo
is used to see the value and you can also addexit 2
at the end to know about the issue and whether the post-commit hook script is running or not.I made a tool using Python with some bash to trigger a Jenkins build. Basically you have to collect these two values from post-commit when a commit hits the SVN server:
Then you use "svnlook dirs-changed $1 -r $2" to get the path which is has just committed. Then from that you can check which repository you want to build. Imagine you have hundred of thousand of projects. You can't check the whole repository, right?
You can check out my script from GitHub.
There are two ways to go about this:
I recommend the first option initially, due to its ease of implementation. Once you mature in your build processes, switch over to the second.
Poll the repository to see if changes occurred. This might "skip" a commit if two commits come in within the same polling interval. Description of how to do so here, note the fourth screenshot where you configure on the job a "build trigger" based on polling the repository (with a crontab-like configuration).
Configure your repository to have a post-commit hook which notifies Jenkins that a build needs to start. Description of how to do so here, in the section "post-commit hooks"
The SVN Tag feature is not part of the polling, it is part of promoting the current "head" of the source code to a tag, to snapshot a build. This allows you to refer to Jenkins buid #32 as SVN tag /tags/build-32 (or something similar).