mohamicorp / stash-jenkins-postreceive-webhook

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

Ways not to notify Jenkins when he's pushing tags ? #173

Open jonathanpelletier opened 8 years ago

jonathanpelletier commented 8 years ago

We are using Bitbucket 4.5.2 (which I'm not an admin of, so I can't access logs) with this webhook to notify our Jenkins jobs of new pushes. I recently added a post-build "Git Publisher" step to tag successful jobs and push it to our Bitbucket server.

Our Jenkins instance has its SSH key setup for system use, as described here: https://confluence.atlassian.com/bitbucketserver/ssh-access-keys-for-system-use-776639781.html. The problem is that the webhook sends a notification to Jenkins when the tag is pushed, triggering a new build. If this new build is successful, it gets tagged, triggers another build, yada, yada, yada.

I tried:

  1. Use in the "Committers to Ignore" field
    • After trying the 20 or so "obvious" possibilities, using the Linux user name, ssh-key email, etc... it never worked. I assume that it is because there is no Bitbucket user account, since the tagging/pushing was done using jenkins, which is allowed to connect to Bitbucket password-less over ssh.
  2. Running tcpdump on Jenkins
    • I never saw a "user" field (or something along the lines of) in the notification messages. I can easily guess that it's not something Bitbucket sends out. So couldn't see if it was a special user name, or just null.
  3. "Branch Options" -> "Ignore From" set to refs/tags/*
    • I thought it would be a clever thing to try, instead of targeting a specific user. No luck there either. The code in BranchEligibilityFilter.java told me after that only branches starting with refs/heads/ can match...

So any idea how I could prevent the webhook from notifying Jenkins when tags are pushed from Jenkins? I'm out of ideas, except doing some dirty build step in our job to stop the infinite build loop.

Thanks

karann-jain commented 7 years ago

Have you tried adding commit message while creating tag and excluding this commit tag using Git Plugin option Polling ignored commits with certain messages?

jonathanpelletier commented 7 years ago

Hum, no I haven't tried to combine this setup with polling options. Now that you mention it, it might work. I'd need to give it a try...

thrownullpointer commented 7 years ago

Can you provide a git log of the commit performed by this user?

MichalMichalak commented 6 years ago

@karann-jain Adding tag message doesn't seem to work because Jenkins does all the filtering only after proper commit is determined. At this point tag information is already lost as tag is just used to determine which commit it point to. So yes, you can filter by message, but it would be a commit message, not a tag's one.