Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excluding .yaml and .md files from auto triggering the Jenkins build

I do not want the Jenkins build to auto trigger when .yaml files and readme files are changed and committed. I am looking for a global function that I can call in my Jenkinsfile.

Any suggestions are appreciated.

Thanks!

like image 809
user3194721 Avatar asked Dec 29 '18 00:12

user3194721


2 Answers

In your job's configuration under the Build Triggers section, you should be able to find what you are looking for (usually under the Advanced tab). For example, on my instance of Jenkins, for the "GitHub Pull Request Builder" trigger type, after clicking the Advanced button, you can see an "Excluded regions" textbox with the following help description:

Each exclusion uses regular expression pattern matching, and must be separated by a new line.

    myapp/src/main/web/.*\.html
    myapp/src/main/web/.*\.jpeg
    myapp/src/main/web/.*\.gif

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

Other trigger types will have something similar to the notion of "Excluded regions".

Moreover, Jenkins has added functionality like this in various ways as discussed in resolved Jira tickets such as JENKINS-21418 and JENKINS-36614.

I hope that helps. I know that it isn't a global function in a Jenkins file, as per the question, but I think that it can be a viable solution to the problem in general.

like image 86
entpnerd Avatar answered Oct 16 '22 22:10

entpnerd


Jenkins declarative language checkout presumably also cover excludedRegions which is the same option @entpnerd described in the GitHub Pull Request Builder plugin:

excludedRegions

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.

See a Jenkinsfile example in a similar stackoverflow question. Jira issue JENKINS-36195 requested for this functionality and JENKINS-36836 provided working and not working cases and why.

The reality is that it is not working and it is not planned to be included:

There have been some brief discussions about it, but there are no plans to address it

so I would go for Jenkins GUI polling configuration.

like image 32
Carlos Cavero Avatar answered Oct 16 '22 21:10

Carlos Cavero