Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Triggering Jenkins job on change only to specific subfolder in job scm folder

I'm migrating continuous integration system from Teamcity to Jenkins. We have a single svn repository for all our projects like this:

project/dev_db_build (folder)
project/module1 (folder)
project/module2 (folder)
projets/pom.xml

For building db on CI server I use url project/dev_db_build and can pol this url to trigger builds when there are changes.

For building application I use url project/ So if I poll it and there are changes to dev_db_build application build should be ignored and triggered after db_build as successful.

In teamcty I used "Trigger patterns" for this. But in Jenkins there are so many triggering plugins https://wiki.jenkins-ci.org/display/JENKINS/Plugins#Plugins-Buildtriggers - I looked into some of them and have not found suitable.

like image 767
Ivan Sopov Avatar asked Nov 07 '11 14:11

Ivan Sopov


2 Answers

Ideally, you should use a post-commit hook as suggested by @Mike, rather than polling. Otherwise, when configuring the Jenkins job, under 'Source Code Management' with 'Subversion' selected, there is an advanced button. Clicking this reveals an number of options, including 'Excluded Regions'

If set, and Jenkins is set to poll for changes, Jenkins will ignore any files and/or folders in this list when determining if a build needs to be triggered. Each exclusion uses regular expression pattern matching, and must be separated by a new line.

/trunk/myapp/src/main/web/.*.html

/trunk/myapp/src/main/web/.*.jpeg

/trunk/myapp/src/main/web/.*.gif

The example above illustrates that if only html/jpeg/gif files have been committed to the SCM a build will not occur. More information on regular expressions can be found here.

In your case, you would set 'Excluded Regions' to something like

/project/dev_db_build/.*
like image 130
Tom Howard Avatar answered Oct 23 '22 03:10

Tom Howard


Do you have the ability to edit your Subversion hooks? Instead of having your Jenkins server poll SVN, I would recommend that you have SVN call Jenkins via a post-commit hook to automatically kick off a build upon developer commit. This has the effect of lessening the load on both the Jenkins and SVN servers as well as not having a waiting period of however long your polling interval is before a build is kicked off.

like image 30
Mike Avatar answered Oct 23 '22 02:10

Mike