1

I am having an issue with my Jenkins pipeline that pushes a tag as one of the steps, this ultimately kicks off the build again causing a loop.

Doesn't GitHub have a way of only sending a webhook with a source commit to the repo and not a tag?

Duker
  • 11
  • 1
  • You may want to turn off tag building in Jenkins. – MaratC Apr 16 '20 at 14:44
  • one of the steps is to create a git tag. Its a shell step defined in the Jenkinsfile – Duker Apr 16 '20 at 17:30
  • Not talking about Jenkinsfile, but rather of your Jenkins configuration, so that Jenkins does not kick off a build when a new tag is created. – MaratC Apr 16 '20 at 20:38
  • Unsure what you mean here of "tag building" where in the configuration would this be adjusted? – Duker Apr 17 '20 at 08:29

1 Answers1

2

When you register for a given type of webhook with GitHub, you get notifications for every webhook of that type. Filtering is not possible for efficiency reasons, since GitHub sends massive numbers of webhook payloads. The assumption is that your service will discard any events you don't care about.

If you don't want Jenkins to build when a tag is pushed, then configure it not to do that. From some quick Googling, it appears you can control the refs to be built, so you may want to configure it to just build refs/heads/*, which doesn't include tags.

bk2204
  • 64,793
  • 6
  • 84
  • 100
  • By using the "Generic Webhook Trigger" as the Build Trigger is this still something that can be achieved? Would be good to see the link you Google'd – Duker Apr 17 '20 at 08:29
  • Okay, I was able to get this working using the "Optional Filter" in the Generic Webhook" config; Post content parameters: variable: branch Expression: $.ref print post content checked print contributed values checked Optional filter: Expression: refs/heads/* Text: $branch – Duker Apr 17 '20 at 11:39
  • @bk2204 / @Duker, where we have to mentioned `refs/heads/*` ? I already motioned in `Jenkins -> Job -> Source Code Management -> Git -> Refspec` but that doesn't help. My value for this field is `+refs/heads/*:refs/remotes/origin/*`, but when there is push event for tag, it still trigger the jenkins job. – Nilesh Jun 14 '22 at 12:20