问题
I'm working with declarative pipeline syntax. My jenkins files are stored on a git hub repository, separated from the code to build, so I set up the jenkins job to get the pipeline script from scm, selecting my git repo on master branch. Within my pipeline script I'm using the checkout step to get my real code from another source (an RTC repository in my case, but I suppose another git repository would be the same scenario). Everything works well and if I enable to trigger the build by polling scm it will start if there are changes in any of the two repository (by design I would say).
My problem is that I would like to avoid to trigger the build if the change happened in the jenkins files repository, but only when it happens in the repository that contain the actual code. In the check-out step it would be easy as there is an option to enable/disable the single poll, but in the job itself I can't find any way to skip polling for the jenkins file repository.
I tried the additional behavior "Don't trigger a build on commit notification" but it does not seems to have effect, at least not in the way I would like.
回答1:
Possible workarounds:
If the webhook is not configured at GitHub org level, disable webhook for the repository where your Jenkinsfile is located
OR
In the Jenkins job configuration, under Pipeline > Additional Behaviours > Add, select Polling ignores commits in certain paths. Then, in the Excluded Regions textbox, specify the Jenkinsfile path or .* to exclude everything.
来源:https://stackoverflow.com/questions/47650259/how-to-exclude-jenkins-files-from-scm-polling-on-a-jenkins-job