Reputation: 611
I'm quite new to Jenkins and CI in general.
Our current SVN setup is made, amongst others, of a big repository containing various projects, organized in subdirectories, which we'd like to start building (and testing, in the future) automatically whenever a particular file per-project is committed to the SVN repo.
My current jobs' setup/workflow in Jenkins is something like that.
This all works correctly, but there's a delay of about a minute from the moment something has been committed to SVN to when Jenkins updates its local copy, and another minute to have the FSTrigger plugin scan for changes in the "trigger files".
I've just implemented a post-commit hook in SVN to solve the first delay, so now no more polling to the SVN repo is made.
Now I'd really like to get rid of the second delay caused by FSTrigger plugin polling every minute (polling is, BTW, a poor technique anyway).
Is there a way to have the first job "call/trigger" the others based on the files just updated, given my trigger condition is a particular file being committed (updated) to the SVN repo for each one of my projects?
Upvotes: 1
Views: 1289
Reputation: 7924
You want to break up with the FSTrigger plugin. As you mentioned polling is poor.
You want to have some logic in your post-commit hook that looks at the paths changed in that commit and fires off requests to start the appropriate build(s).
I don't use jenkins or svn anymore so I can't really test. Something like:
svnlook changed -t "$TXN" "$REPOS
should get you the paths changed.
Then fire a request to jenkins to build a job based on which paths you find in the svnlook
output:
curl --user $JENKINS_USER:$JENKINS_API_TOKEN http://jenkins/job/build-name/build
Note from the OP: This is how I implemented it in my post-commit hook:
REPOS="$1"
REV="$2"
svnlook changed --revision $REV $REPOS |
#logic to filter the trigger file and to create the job name from it |
while read -r JOBNAME ; do
/usr/bin/wget \
--output-document "-" \
--timeout=30 \
--tries=1 \
http://JENKINS_SERVER/job/$JOBNAME/build
done
It works great!
Upvotes: 2