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

11,817

Solution 1

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/.*

Solution 2

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.

Share:
11,817
Ivan Sopov
Author by

Ivan Sopov

Java developer On Github

Updated on July 20, 2022

Comments

  • Ivan Sopov
    Ivan Sopov over 1 year

    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.

  • Ivan Sopov
    Ivan Sopov over 12 years
    Thanks a lot. Unfortunately post-commit hooks are not an option right now.