1

I want to build the latest git tag in a Jenkins pushed to a git (GitLab) repository. A web hook for tag pushes is configured and working.

My current try is to setup a parametrized Jenkins job, so it lists me the tags in a git repostiory: Git Parameters Configuration. I don't get some things working: Trigger a build on a tag push. And automatically building this tag.

Since I found nothing on the web or in the Jenkins docs, that helps me implementing this, maybe someone here can help?

Thanks

Michael W
  • 111
  • 1
  • 3

1 Answers1

1

I think you can use Jenkins GitLab plugin. This plugin adds an option to your jobs to "Build when a change is pushed to GitLab" and gives URL for Gitlab webhook.

So, when you setup your webhook in Gitlab and create Jenkins job, Gitlab will be triggered after creating and pushing tag to your repository and will call Jenkins with the provided URL. Jenkins jobs will be triggered and job will start.

toshyak
  • 361
  • 4
  • 10
  • As I wrote in my question, the hook is not the problem. It's already working via the GitLab Web Hooks plugin. It builds branches for me. What I want now is build pushed tags. – Michael W Apr 28 '16 at 14:01
  • @MichaelW after installing GitLab Plugin for Jenkins you will have [option](http://prntscr.com/axwvor) "Build when a change is pushed to GitLab" in Build triggers section – toshyak Apr 28 '16 at 14:20
  • If you've configured the web-hook to trigger a build for each new tag, the tag-name should be among the environment-variables available during the build. Add a shell build-step with just `env` as the command to dump all environment-variables available -- and see, if the tag is there... (On Windows a cmd build-step consisting of `set` should do the same thing.) – Mikhail T. Jan 04 '22 at 20:05