None of these answers were sufficient for me using Jenkins CI v.1.555, Git Client Plugin v.1.6.4 and Git Plugin 2.0.4.
I need the task to be created for one Git repository for one specific, fixed (i.e. non-parameterized) tag. I had to assemble a solution from various answers, and “create a Git tag” is quoted by Thilo .
- Make sure you push your tag to the remote repository using
git push --tags - In the "Git Repository" section of your assignment, in the "Source Control" section, click "Advanced."
- In the Refspec field, add the following text:
+refs/tags/*:refs/remotes/origin/tags/* - In the "Branches for assembly", "
*/tags/<TAG_TO_BUILD> " section, put */tags/<TAG_TO_BUILD> (replacing <TAG_TO_BUILD> with your actual tag name).
Adding Refspec was critical for me. Although it seemed that the Git repositories were retrieving all the deleted information by default, when I left it empty, the Git plugin, however, could not completely find my tag. Only when I explicitly indicated “get deleted tags” in the Refspec field was there a Git plugin that could identify and build from my tag.
Update 2014-5-7 . Unfortunately, this decision is really associated with an undesirable side effect for Jenkins CI (v.1.555) and the Git à la Stash Webhook repository release notification mechanism for Jenkins : whenever a branch in the repository is updated in push, tag creation tasks work again. This leads to a lot of unnecessary re-construction of the same tags over and over again. I tried to set up tasks with and without the Force polling using workspace parameter, and this seemed to have no effect. The only way I could prevent Jenkins from making unnecessary assemblies for tagging is to clear the Refspec field (i.e. Delete +refs/tags/*:refs/remotes/origin/tags/* ).
If someone finds a more elegant solution, edit this answer with an update. I suspect, for example, that perhaps this will not happen if refspec was definitely +refs/tags/<TAG TO BUILD>:refs/remotes/origin/tags/<TAG TO BUILD> , and not just an asterisk. At the moment, however, this solution works for us, we simply remove the additional Refspec after the successful completion of the task.
gotgenes Mar 30 '14 at 17:18 2014-03-30 17:18
source share