A
A
Alex2016-09-08 17:41:17
git
Alex, 2016-09-08 17:41:17

Jenkins: how to run build only when there is a new tag in git?

Hello everyone,
I ran into a seemingly trivial task in Jenkins - you need to run build when a new tag with a specific name hits, for example build_[0-9]{6,10} . The code itself is stored on github, since the rights are limited, I use SCP Polling to poll for changes.
It would seem that everything should be very simple, but in reality it turned out that it was not. I use the following options

Name: origin
Refspec: +refs/tags/*:refs/remotes/origin/tags/*
Branch Specifier: :.*/tags/build_[0-9]{6,10}$

For example we have the following story
550313e  -> 22ce31f -> e31e663 -> e4c4bf6 (head)
  tag1       tag2        tag3       tag4

In this case, everything works as expected, each time a new tag appears, Jenkins runs build, i.e. with the following commands
$ git tag build_000002 550313e && git push --tags -u origin
$ git tag build_000003 22ce31f && git push --tags -u origin
$ git tag build_000004 e31e663 && git push --tags -u origin
$ git tag build_000001 e4c4bf6 && git push --tags -u origin

4 builds will be launched. But, if we first tag the head, then the assembly will be launched only for the head, for the remaining 3 tags it will be ignored.
550313e  -> 22ce31f -> e31e663 -> e4c4bf6 (head)
  tag2       tag3        tag4       tag1

$ git tag build_000001 e4c4bf6 && git push --tags -u origin
$ git tag build_000002 550313e && git push --tags -u origin
$ git tag build_000003 22ce31f && git push --tags -u origin
$ git tag build_000004 e31e663 && git push --tags -u origin

Is it possible to implement this behavior without bicycles and manual filtering of tags?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Shumkin, 2016-09-15
@ashumkin

wait wait? why does your build pass only in releases? ))
Do you have CI?
CI is a build for each repository change
ZY I use another CI server (QuickBuild), I have the following scheme:
for each commit - assembly (compilation, tests)
and when we make a release, then it is the commit that successfully completed the assembly
and the SERVER ITSELF already re-builds with the keys , like, "This is Release", the tests no longer run, tk. this commit puts a tag on this commit, and pushes the tag to the "central" repository
, as for me, this is a more correct scheme

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question