Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins create build from git tags

Tags:

git

jenkins

I'm trying to configure Jenkins to create the builds form git's tags. So what I want is the developers to create a tag (in any branch) and Jenkins will take care of the new build.

I followed this tutorial, but I didn't manage it, can anybody help me?

http://erics-notes.blogspot.nl/2013/05/jenkins-build-latest-git-tag.html

like image 501
Joan P.S Avatar asked Feb 03 '26 20:02

Joan P.S


1 Answers

My task was to make Jenkins build every tag once. Tags may be pushed one by one or all together. Master branch should also be built every time the build is triggered.

I also followed this tutorial and it worked for me in one project and didn't work in another. All Jenkins settings were the same, but in one project the tags were set by a third party build tool (leiningen), and it worked ok. In another project they were set manually (git tag TAG_NAME) and it didn't work.

After some research it came out that tags must be annotated (git tag -a TAG_NAME -m "Message") or signed (git tag -s TAG_NAME -m "Message"). Leiningen internally makes signed tags.

Otherwise Jenkins filters tags out when doing non-tip filtering. (You can see it if you turn on verbose logging by starting jenkins with -Dhudson.plugins.git.GitSCM.verbose=true option). In my case it filtered out all tags and built only master.

You can tell annotated tag from unannotated by running git log in Jenkins workspace directory (<Jenkins>/jobs/<project_name>/workspace).

Annotated logs appear as:

tag: annotated-tag, tag: origin/tags/annotated-tag

While unannotated tags lack the tag: prefix before remote ref:

tag: unannotated-tag, origin/tags/unannotated-tag

Hope that helps!

like image 115
Dmitrii Balakhonskii Avatar answered Feb 05 '26 12:02

Dmitrii Balakhonskii