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

733 views
Skip to first unread message

Cyril

unread,
Sep 23, 2016, 5:57:58 PM9/23/16
to Jenkins Users

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 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 don't want the job to be triggered when I make changes to the scripts. I only want it to be triggered when a change is pushed to the repo that the script does a checkout on.


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.

Indra Gunawan (ingunawa)

unread,
Sep 23, 2016, 7:59:27 PM9/23/16
to jenkins...@googlegroups.com
If you are using “Pipeline script from SCM” and this is on repoB, the pipeline job will trigger when a change/commit pushed to repoB where the pipeline script exists.  
In the pipeline script, even if you are “checkout poll: true, … From repoA” it does not matter.  

You should move the Pipeline script/Jenkinsfile to repoA instead.

-Indra

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/eb6a4d98-6686-46f6-a411-cc60308f76d3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Indra Gunawan (ingunawa)

unread,
Sep 23, 2016, 8:35:11 PM9/23/16
to jenkins...@googlegroups.com
Your best bet is to trigger the pipeline job in your SCM's post-receive hook installed on repoA.

From: <jenkins...@googlegroups.com> on behalf of Cyril <cyril....@gmail.com>
Reply-To: "jenkins...@googlegroups.com" <jenkins...@googlegroups.com>
Date: Friday, September 23, 2016 at 2:57 PM
To: Jenkins Users <jenkins...@googlegroups.com>
--

Indra Gunawan (ingunawa)

unread,
Sep 23, 2016, 8:35:27 PM9/23/16
to jenkins...@googlegroups.com
Or create old-style job configured to trigger on polling of repoA and it will trigger the pipeline job as “Trigger/call builds on other projects” build step.


From: <jenkins...@googlegroups.com> on behalf of Cyril <cyril....@gmail.com>
Reply-To: "jenkins...@googlegroups.com" <jenkins...@googlegroups.com>
Date: Friday, September 23, 2016 at 2:57 PM
To: Jenkins Users <jenkins...@googlegroups.com>
--

Cyril

unread,
Sep 23, 2016, 8:40:43 PM9/23/16
to Jenkins Users, ingu...@cisco.com
So, then I don't understand the option: "Don't trigger a build on commit notifications". What is that supposed to do?

Is there any other way not to trigger the build when changes happen to repoB? Putting the script in repoA is not an option because that same script is used with different repos, so I would have to put that script in each repo which means that any changes will have to be duplicated every time.

Cyril

unread,
Sep 23, 2016, 8:43:36 PM9/23/16
to Jenkins Users, ingu...@cisco.com
I didn't think about that option and it sounds like this should work exactly like I need it to be. Thanks for the suggestion.

I would still like to know what "Don't trigger a build on commit notifications" is supposed to do.

Indra Gunawan (ingunawa)

unread,
Sep 24, 2016, 11:49:37 AM9/24/16
to jenkins...@googlegroups.com
If you do not want the pipeline to be triggered at all by commits to RepoB where the pipeline script exists then remove the Poll SCM in the pipeline job.
In the pipeline job, you configured “Pipeline script from SCM” and specified RepoB as location for the pipeline script.  The "Poll SCM” section will poll RepoB not RepoA.  Therefore, remove “Poll SCM”.
Don’t tell me you choose “Multiple SCM” one for RepoB and one for RepoA.  

Your pipeline script will do the checkout of RepoA not using pipeline job definition to define RepoA to checkout.

If the SCM chosen is “Git” the Pipeline’s “Pipeline script from SCM” reuse Git Plugin and "Don't trigger a build on commit notifications” is the same option in “Additional Behaviours” like other job using Git plugin.
You see the ? Of the option, it says :

"If checked, this repository will be ignored when the notifyCommit-URL is accessed regardless of if the repository matches or not.”


Basically you setup a post-receive git hook on the git remote repository side to push notification to Jenkins.
Are you using this or not?
 
Enabling "Don't trigger a build on commit notifications” means the build won’t trigger even if notifyCommit is received.





Cyril

unread,
Sep 26, 2016, 3:54:45 PM9/26/16
to Jenkins Users, ingu...@cisco.com
I'm not sure what you mean by "Multiple SCM". I don't see that option anywhere so I guess I'm not using it.

I am currently not using git hooks to trigger builds. I thought that the job was supposed to be configured with Polling for it to work but it looks like I misunderstood, and that I just need to have polling set to true (which is the default if not specified) when doing the checkout out in my pipeline script and polling off on the job. I think I now understand what needs to be done for this to work the way I intended. I will try and report back if I encounter any issues. The option "Don't trigger on commit notifications" also makes more sense now.

Cyril

unread,
Sep 26, 2016, 4:32:54 PM9/26/16
to Jenkins Users, ingu...@cisco.com
Actually, looking at the comments for the git hook feature, it seems that I still need to have Polling enabled on the job or it won't work. Leaving the schedule blank should work though. I will try that as soon as we can setup the hook on the remote.

Cyril

unread,
Sep 27, 2016, 1:07:00 PM9/27/16
to Jenkins Users, ingu...@cisco.com
Everything is now working as expected. In case some people have the same issues, here is a recap of what needs to be done:
  • 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

Cosmo

unread,
Nov 22, 2017, 1:17:28 PM11/22/17
to Jenkins Users
@Cyril -- I am having the same issue as in your original post. I don't understand your solution though. I have webhooks defined for my RepoA and RepoB. In the "Build Triggers" section of the job config I have only "Github hook trigger" -- presumably this will only trigger a build on pushes to RepoA (listed in my "checkout" stage of the script). RepoB, containing the script, is only listed in the pipeline definition as "Pipeline script from SCM." When you say, "Make sure polling is enabled...," do you mean enabled in the "Build Triggers" section or the "Additional Behaviors" under the "Pipeline Definition" section? There are several polling-related options in the latter.

I don't see how enabling polling (with blank spec) will serve to ignore commits to RepoB, especially with "Don't trigger a build on commit notifications" removed. Can you explain please? Why would that ignore commits to RepoB and not to RepoA?



This electronic communication and any attachments may contain confidential and proprietary information of DigitalGlobe, Inc. If you are not the intended recipient, or an agent or employee responsible for delivering this communication to the intended recipient, or if you have received this communication in error, please do not print, copy, retransmit, disseminate or otherwise use the information. Please indicate to the sender that you have received this communication in error, and delete the copy you received.

DigitalGlobe reserves the right to monitor any electronic communication sent or received by its employees, agents or representatives.

Cyril

unread,
Nov 30, 2017, 1:48:52 PM11/30/17
to Jenkins Users
Hi Cosmo. Sorry for the late response, I was on vacation. Unfortunately I don’t think I can be very helpful as I don’t work in the same company anymore and I don’t remember what I did exactly even after reading all the messages again. I’m pretty sure that I did not do anything else than what is mentioned in my last post. I would suggest to post a new question and see if someone has a better solution. The behavior of the plugins and/or Jenkins may have changed since so maybe this is not valid anymore.
Also I think we didn’t have any Git hooks set up for the repo containing the Jenkins scripts.
Reply all
Reply to author
Forward
0 new messages