Jenkins builds being triggered despite “Don't trigger a build on commit notifications”

社会主义新天地 提交于 2019-12-08 03:02:48

问题


I have a Pipeline job that checkouts a git repository (let's call is "repoA") and passes it to some other downstream jobs for further processing. The upstream job's script is stored in a different git repo (let's call it "repoB"). This job is configured with the "Poll SCM" option so that any changes to repoA will trigger it. In the pipeline section, I have selected the "Pipeline script from SCM" option and configured it to get the pipeline script from the master branch of repoB. I have also added the option "Don't trigger a build on commit notifications". The behavior that I'm expecting is that any changes pushed to repoA would trigger the job, and any changes to repoB would not trigger the job. Yet, when I push a change to repoB, the job is triggered.

I don't know if this is a bug, or if I'm missing something.

I am running Jenkins 2.7.4. My master Jenkins is running on Ubuntu server 16.04.1 LTS. All my Jenkins plugins are up to date.


回答1:


After some exchange with the Jenkins mailing list, I now understand better how things work so here is what I had to do in case other people need it:

  • Create a git hook to notify Jenkins that changes have been committed/pushed: on our end we created a post-receive hook on the remote
  • Enable polling on your job but leave the schedule empty
  • In the Pipeline section, configure it to pull the groovy script from your git repo (in my example it is repoB) but don't add the behavior: "Don't trigger a build on commit notifications"
  • Make sure polling is enabled when you checkout your git repository (in my example it is repoA) in your script: by default it is enabled if you don't specify it

As far as I understand, the option "Don't trigger a build on commit notifications" is for notifications comming from the hooks and not from the job polling schedule as I first thought.



来源:https://stackoverflow.com/questions/39626345/jenkins-builds-being-triggered-despite-dont-trigger-a-build-on-commit-notifica

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!