Jenkins: Don't want to trigger on Git Tag (No Workspace)
I have users who need to trigger jenkins jobs on Github (Enterprise) pushes. So all I have access to are Webhooks, and the Git Service hooks. These hooks push even if the only commit was a tag.
Some users auto-tag their builds if they succeed, this auto-tag causes a new webhook to fire and it triggers their build again.
Typically we were avoiding this by using the git plugins “exclude user” section and setting a list of service accounts on that list that do the tagging.
However with the advent of our new ephemeral build farm, we don’t maintain workspaces anymore (we spin nodes up as Docker containers on demand). So this approach no longer works (see: https://issues.jenkins-ci.org/browse/JENKINS-29282).
My temporary work around is that I run a shell script as the first build step which now does some git-log compares and aborts the build if the service account was the only committer.
I’m looking for a way to use a git hook to trigger a build that does not even start the build if it was just a tag event.
This would appear to be an a difficult ask, but I feel like this problem has to be pretty common. Many people must auto-tag Git after a build runs successfully and avoid rebuilding.
One Solution collect form web for “Jenkins: Don't want to trigger on Git Tag (No Workspace)”
I know this question is getting old, but I recently had a similar problem with Bitbucket’s webhook to Jenkins that would send out notifications of push changes for tags. I tried configuring the hook not to send those, but it never worked.
After much trial and error, the only thing that worked for me was to set the “Branch Specifier (blank for ‘any’)” field of the Jenkins Git Plugin to “everything but tags”, using a regex like this one:
I admit that this solution has the major drawback that a job with such a configuration cannot build tags… In my case, the set of jobs that had this configuration wasn’t expected to build tags, so it was an okay solution, but I would have much preferred to remove the notifications.
Hope this helps.