mohamicorp / stash-jenkins-postreceive-webhook

Webhook used to notify Jenkins when commits are made to Stash
Other
138 stars 98 forks source link

Webhook trigering multiple builds #59

Closed phardakerffdc closed 10 years ago

phardakerffdc commented 10 years ago

Hi,

we're making heavy use of your webhook and firstly I'd like to say how fantastic it is!

We have one slight issue - we have multiple jenkins jobs pointing at the same Stash repo, each job configured to build a different branch.

What I'm seeing is, when I push to one branch, the build for that branch is triggered, but also builds for other branches too.

Could this be a problem in the way I've set things up? Am I misunderstanding something? Or could it be a bug in the webhook?

Many thanks

kuhnroyal commented 10 years ago

Jenkins can not be notified to build a specific branch. The notification triggers a poll for changes, any changes will be build. Hope that helps. Am 27.03.2014 09:50 schrieb "comic96" notifications@github.com:

Hi,

we're making heavy use of your webhook and firstly I'd like to say how fantastic it is!

We have one slight issue - we have multiple jenkins jobs pointing at the same Stash repo, each job configured to build a different branch.

What I'm seeing is, when I push to one branch, the build for that branch is triggered, but also builds for other branches too.

Could this be a problem in the way I've set things up? Am I misunderstanding something? Or could it be a bug in the webhook?

Many thanks

— Reply to this email directly or view it on GitHubhttps://github.com/Nerdwin15/stash-jenkins-postreceive-webhook/issues/59 .

phardakerffdc commented 10 years ago

But our Jenkins jobs are configured to build specific branches? For example:

Job1 builds only branch1 Job2 builds only branch2

Pushing changes to branch2 causes Job2 to run as you'd expect, but Job1 also gets triggered.

Nothing has changes on branch1 so why should it build?

kuhnroyal commented 10 years ago

This plugin basically only says 'Hey Jenkins, there a changes in repository xyz, go and check!'. It has nothing to do with what is build in Jenkins. If your builds are setup correctly then there might be something wrong with the git polling log on Jenkins, the Jenkins Git plugin had problems with that in the past.

phardakerffdc commented 10 years ago

Ok thanks I will do some more investigating when I get time :-)

mikesir87 commented 10 years ago

Thanks Peter for answering. I've been under the weather with bronchitis, so have been offline the past few days. Hope to get over that soon!

@comic96 - as Peter mentioned, the plugin doesn't provide any indication of the branch that had a change. I have seen a few setups in which there is a Jenkins job for the master branch and another job to cover all other branches.

The endpoint that the plugin contacts in Jenkins does permit the ability for the plugin to say "This was the branch that changed", but I'm not sure it would be of much benefit as that would be discovered during the Git poll that Jenkins does right then anyways. So, I don't plan on using that functionality in the plugin.

mikesir87 commented 10 years ago

Going to go ahead and close this as it's not an issue with our side of things. However, feel free to continue the conversation if you wish. I don't mind helping someone out! :)

groves commented 10 years ago

If including the branches would keep Jenkins from polling as long as a build didn't point at those branches, I believe it'd fix a problem for us.

We have a build that deploys our stable branch that we'd like to run hourly if the stable branch has changed and not otherwise. We can exclude notifications for changes to the stable branch with the "Ignore from" option on the webhook. That keeps pushes to that branch from triggering anything.

However, this sequence still causes it to build:

  1. Someone pushes to stable. Nothing is triggered because stable is ignored.
  2. Someone pushes to master. This triggers a Jenkins poll.
  3. The build pointing at stable notices the change from 1 in its poll and it builds, even though the hour hasn't passed.

If including the branches kept the build pointing at stable from polling if stable wasn't included, I think we'd be golden.

ixre commented 5 years ago

@phardakerffdc hi, i have same needes.

ixre commented 5 years ago

@phardakerffdc

Hi, I have the same needs. you can pass Build when a change is pushed to GitLab -> Allowed branches settings caught one trigger. hope it's helpfully for you.