Git push to specific branch on multibranch pipelines builds all branches

1,316 views
Skip to first unread message

Harlan Barnes

unread,
Nov 22, 2017, 10:17:48 AM11/22/17
to Jenkins Users
Hello Jenkins Friends,

I'm having a problem getting the configuration correct for my multi-branch pipeline. Here are the details

* I have a Jenkins job configured with a simple Git Branch Source with the following options:
  * Discover All Sources
  * Filter by name (with regular expression): (master|v\d+\.\d+) ... this should pick up master and v1.14, v1.15, etc.

* I see the current expected list of branches appear for building: master and v1.14

* The Jenkinsfile for both branches is the same (v1.14 is a branch of master) and has the following setup for triggering with a github push:

          properties([
            pipelineTriggers([triggers: [[$class: "GitHubPushTrigger"]]])
          ])

* When I push a change to master, both the "master" and the "v1.14" branches build.

* The Github Hook Log for master is below and looks about what I would expect:

Started on Nov 21, 2017 6:26:55 PM
Started by event from 192.30.252.34 ⇒ http://not.the.real.hostname/github-webhook/ on Tue Nov 21 18:26:55 UTC 2017
Using strategy: Specific revision
[poll] Last Built Revision: Revision 69062e9fb06a7b458642c35bc07aaea1e3794cdc (master)
 > git ls-remote -h g...@github.com:FakeOrg/FakeRepo.git # timeout=10
Found 91 remote heads on g...@github.com:FakeOrg/FakeRepo.git
[poll] Latest remote head revision on refs/heads/master is: 3fc35f5d4619a6e8bdcdec490e25378e64b674e0
Using strategy: Default
[poll] Last Built Revision: Revision 69062e9fb06a7b458642c35bc07aaea1e3794cdc (master)
 > git ls-remote -h g...@github.com:FakeOrg/FakeRepo.git # timeout=10
Found 91 remote heads on g...@github.com:FakeOrg/FakeRepo.git
[poll] Latest remote head revision on refs/heads/master is: 3fc35f5d4619a6e8bdcdec490e25378e64b674e0
Done. Took 0.48 sec
Changes found

* The Github Hook Log for v1.14 starts out okay, but then says it's checking "master" too:

Started on Nov 22, 2017 3:05:52 PM
Started by event from 192.30.252.45 ⇒ http://not.the.real.hostname/github-webhook/ on Wed Nov 22 15:05:52 UTC 2017
Using strategy: Specific revision
[poll] Last Built Revision: Revision 6b49bb9293b66ba6f19500b7613c992ba49dfdc6 (v1.14)
 > git ls-remote -h g...@github.com:FakeOrg/FakeRepo.git # timeout=10
Found 91 remote heads on g...@github.com:FakeOrg/FakeRepo.git
[poll] Latest remote head revision on refs/heads/v1.14 is: 6b49bb9293b66ba6f19500b7613c992ba49dfdc6 - already built by 2
Using strategy: Default
[poll] Last Built Revision: Revision 6b49bb9293b66ba6f19500b7613c992ba49dfdc6 (v1.14)
 > git ls-remote -h g...@github.com:FakeOrg/FakeRepo.git # timeout=10
Found 91 remote heads on g...@github.com:FakeOrg/FakeRepo.git
[poll] Latest remote head revision on refs/heads/master is: 017f8e7c0c8ba5e064418a4445aaef3f4bee13c1
Done. Took 0.45 sec
Changes found

* As you can see in the v1.14 hook log, it says that the v1.14 branch was already build by build id #2 ... but then it goes on to check the head revision against "ref/heads/master" and says it's different and "changes found".

Can anyone point me to the detail I'm missing in this configuration?

Thanks,

Harlan Barnes

Stephen Connolly

unread,
Nov 22, 2017, 10:49:49 AM11/22/17
to jenkins...@googlegroups.com
On 22 November 2017 at 15:17, Harlan Barnes <harlan...@gmail.com> wrote:
Hello Jenkins Friends,

I'm having a problem getting the configuration correct for my multi-branch pipeline. Here are the details

* I have a Jenkins job configured with a simple Git Branch Source with the following options:
  * Discover All Sources
  * Filter by name (with regular expression): (master|v\d+\.\d+) ... this should pick up master and v1.14, v1.15, etc.

* I see the current expected list of branches appear for building: master and v1.14

* The Jenkinsfile for both branches is the same (v1.14 is a branch of master) and has the following setup for triggering with a github push:

          properties([
            pipelineTriggers([triggers: [[$class: "GitHubPushTrigger"]]])
          ])

Dont do that.

Multibranch is opinionated, if you have set up your webhook correctly, you are done. That config is what is causing your issue
 

--
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-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/b6f0e7a1-36ea-48ba-9837-e43156389c90%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Stephen Connolly

unread,
Nov 22, 2017, 10:50:52 AM11/22/17
to jenkins...@googlegroups.com
On 22 November 2017 at 15:49, Stephen Connolly <stephen.al...@gmail.com> wrote:
On 22 November 2017 at 15:17, Harlan Barnes <harlan...@gmail.com> wrote:
Hello Jenkins Friends,

I'm having a problem getting the configuration correct for my multi-branch pipeline. Here are the details

* I have a Jenkins job configured with a simple Git Branch Source with the following options:
  * Discover All Sources
  * Filter by name (with regular expression): (master|v\d+\.\d+) ... this should pick up master and v1.14, v1.15, etc.

* I see the current expected list of branches appear for building: master and v1.14

* The Jenkinsfile for both branches is the same (v1.14 is a branch of master) and has the following setup for triggering with a github push:

          properties([
            pipelineTriggers([triggers: [[$class: "GitHubPushTrigger"]]])
          ])

Dont do that.

Multibranch is opinionated, if you have set up your webhook correctly, you are done. That config is what is causing your issue.

To clarify, multibranch automatically detects those push events and handles them automatically.

Harlan Barnes

unread,
Nov 22, 2017, 12:31:05 PM11/22/17
to Jenkins Users

On Wednesday, November 22, 2017 at 10:50:52 AM UTC-5, Stephen Connolly wrote:

* The Jenkinsfile for both branches is the same (v1.14 is a branch of master) and has the following setup for triggering with a github push:

          properties([
            pipelineTriggers([triggers: [[$class: "GitHubPushTrigger"]]])
          ])

Dont do that.

Multibranch is opinionated, if you have set up your webhook correctly, you are done. That config is what is causing your issue.

To clarify, multibranch automatically detects those push events and handles them automatically.
 
Well, I only added it after I couldn't get commits to trigger builds to start with. From some Googling, I saw some folks using that so I thought it was required to trigger it on push events.

But I tried it now just to be sure. I removed it, deleted the job and rebuilt it from scratch, and now the job won't trigger at all on commits.

I re-configured my webhooks (they are set at the Organization level ... I tried them at the repository level as well and it didn't work either.)

I can't find a webhook log now either ... although I see the event being received in my log:

Nov 22, 2017 5:13:53 PM org.jenkinsci.plugins.github_branch_source.PushGHEventSubscriber onEvent

Is that the right webhook event handler? There's so many of them I can't tell if one plugin is affecting another.

Harlan Barnes

unread,
Feb 8, 2018, 12:39:39 PM2/8/18
to Jenkins Users

On Wednesday, November 22, 2017 at 10:50:52 AM UTC-5, Stephen Connolly wrote:


On 22 November 2017 at 15:49, Stephen Connolly <stephen.al...@gmail.com> wrote:

On 22 November 2017 at 15:17, Harlan Barnes <harlan...@gmail.com> wrote:
Hello Jenkins Friends,

I'm having a problem getting the configuration correct for my multi-branch pipeline. Here are the details

* I have a Jenkins job configured with a simple Git Branch Source with the following options:
  * Discover All Sources
  * Filter by name (with regular expression): (master|v\d+\.\d+) ... this should pick up master and v1.14, v1.15, etc.

* I see the current expected list of branches appear for building: master and v1.14

* The Jenkinsfile for both branches is the same (v1.14 is a branch of master) and has the following setup for triggering with a github push:

          properties([
            pipelineTriggers([triggers: [[$class: "GitHubPushTrigger"]]])
          ])

Dont do that.

Multibranch is opinionated, if you have set up your webhook correctly, you are done. That config is what is causing your issue.

To clarify, multibranch automatically detects those push events and handles them automatically.

 After a lot of testing on and off, I found that Multi branch will ONLY detect these push events if it is used in with the Organization plugin. It won't detect them if you just use the MultiBranch Pipeline standalone. We don't use the Organization plugin for various reasons. I could be missing something, but I've been fighting with this thing for months and gotten nowhere.

If anyone has any suggestions, I'm all ears. :-)

Tomas Bjerre

unread,
Apr 1, 2018, 2:30:26 PM4/1/18
to Jenkins Users
Reply all
Reply to author
Forward
0 new messages