Jonathan Perry
Jonathan Perry

Reputation: 3053

Move same git tag to the latest push using Jenkins

I have a Jenkins build configured to run on each push, I want to tag the latest push with a latest tag for a process that runs on pushes with that tag only.

I've tried to create a post-build event that updates a latest tag on the origin remote name, but that works only the first time, next push will cause a Updates were rejected because the tag already exists in the remote. error.

Here's my configuration in Jenkins: My Jenkins configuration

Any ideas on how to remove the old latest tag and move it to the newly pushed version on Jenkins?

Upvotes: 2

Views: 735

Answers (1)

lvthillo
lvthillo

Reputation: 30723

Just execute a script before you tag which deletes the previous latest tag:

# delete local tag 'latest'
git tag -d latest
# delete remote tag 'latest' (eg, GitHub version too)
git push origin :refs/tags/latest

reference here.

Upvotes: 1

Related Questions