Enabling Jenkins to Build Git Tags

10,400 views
Skip to first unread message

ryenus

unread,
Apr 7, 2013, 3:34:22 AM4/7/13
to jenkin...@googlegroups.com, jenkins...@googlegroups.com
Is there anyone interested in allowing Jenkins to build tags as well other than just branches?

In our team, we have a special requirement that every tag pushed to our Git repository should trigger a Jenkins build. We've done that via some customization to the Jenkins Git Plugin:

I've attached the patch (based on git-1.2.0), and a screen shot of the result build configuration section and it's working as expected.

Notes:
1. The patch is made in a way that by default nothing would be changed.
2. By setting the 'Tags to build' field, you can specify shell patterns as in `git tag -l <pattern>` to specify the tags to be built.
3. By checking the 'Don't build branches' checkbox, branches can be skipped

I'm curious about whether this could be adopted by the community, and how? I'd love to hear your feedback.

Cheers

jenkins.jpg
git-build-tags.patch

domi

unread,
Apr 7, 2013, 7:13:49 AM4/7/13
to jenkin...@googlegroups.com, jenkins...@googlegroups.com
that sounds like a good thing, but why you still show the "Branches to build" if you checked the option "Don't build branches" - I think it would make more sense to hide the the branches in that case.
To get a better feedback, you should just open an issue and send a pull request on GitHub.
/Domi


--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
<jenkins.jpg><git-build-tags.patch>

Christopher Orr

unread,
Apr 8, 2013, 8:49:29 AM4/8/13
to jenkin...@googlegroups.com
Hi there,

You can already do most of this with (for example):

Refspec: +refs/tags/beta/*:refs/remotes/origin/tags/beta/*
Branch spec: */tags/beta/*

We use that config to cause a build only when a new tag called
"beta/whatever" is pushed. No branches are built.

I think the one thing missing that you've added is the full wildcard
support. So maybe it would be better to add generic full wildcard
support to ref- and branch-specs, rather than adding this tag-specific
feature?

Maybe Nicolas has some other ideas...

Regards,
Chris

Jon Schewe

unread,
Apr 11, 2013, 9:20:08 PM4/11/13
to jenkin...@googlegroups.com
Are you saying that I should put "+refs/tags/*:refs/remotes/origin/tags/*" in the Refspec field under advanced and "*/tags/*" in the branch specifier and that will build only tags?



For more options, visit https://groups.google.com/groups/opt_out.


--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-dev+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.


Sean Jones

unread,
Aug 27, 2014, 12:22:57 PM8/27/14
to jenkin...@googlegroups.com, jpsc...@mtu.net
Does this work? I have been attempting to do this but the latest commit from master is always built.

For more options, visit https://groups.google.com/groups/opt_out.



--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.


Mark Waite

unread,
Aug 27, 2014, 9:50:16 PM8/27/14
to jenkin...@googlegroups.com
It works for me using the latest git plugin (2.2.5) and the latest git client plugin (1.10.1).

I created a job which takes a parameter TAG_TO_BUILD

I enabled Git as the SCM system, and used git://github.com/jenkinsci/git-client-plugin.git as the URL for the repository.

I changed the "Branches to build" from the default "*/master" to "refs/tags/${TAG_TO_BUILD}".  That syntax is listed in the help for the "Branches to build" field as one which will build that specific tag.

I added a build step "git log -n 2" to report the last commit.

I ran the job several times, giving values like "git-client-1.10.1" and "git-client-1.6.4" and "git-client-1.9.0".  Each time, the console output showed that the matching git commit had been used for the checkout.

Alexander Link implemented that enhancement with his fixes in git client plugin 1.10.0.  Refer to the https://wiki.jenkins-ci.org/display/JENKINS/Git+Client+Plugin#GitClientPlugin-ChangeLog for links to the two bugs which were fixed with that change.

Thanks,
Mark Waite


For more options, visit https://groups.google.com/d/optout.



--
Thanks!
Mark Waite
Reply all
Reply to author
Forward
0 new messages