New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: automatically create (and push) Git tag after successful build #1476

Closed
wireframe opened this Issue Oct 2, 2013 · 17 comments

Comments

Projects
None yet
@wireframe

wireframe commented Oct 2, 2013

I'm able to (kindof) accomplish this via .travis.yaml after_success, but it's clunky to say the least and seems like a prime candidate for some kind of support built right into travis.

example work around:

after_success:
  - git config --global user.email "builds@travis-ci.com"
  - git config --global user.name "Travis CI"
  - export GIT_TAG=build-$TRAVIS_BRANCH-$(date -u "+%Y-%m-%d-%H-%M-%S")-$TRAVIS_BUILD_NUMBER
  - git tag $GIT_TAG -a -m "Generated tag from TravisCI build $TRAVIS_BUILD_NUMBER"
  - git push origin $GIT_TAG
@sarahhodne

This comment has been minimized.

Show comment
Hide comment
@sarahhodne

sarahhodne Oct 4, 2013

Contributor

This could be another deployment provider if we choose to add it.

Contributor

sarahhodne commented Oct 4, 2013

This could be another deployment provider if we choose to add it.

@roidrage

This comment has been minimized.

Show comment
Hide comment
@roidrage

roidrage Dec 10, 2013

Member

Just noting that this would require people to give us some sort of write access to their repositories. For public repositories I'm guessing not a lot of people would appreciate that.

Member

roidrage commented Dec 10, 2013

Just noting that this would require people to give us some sort of write access to their repositories. For public repositories I'm guessing not a lot of people would appreciate that.

@sarahhodne

This comment has been minimized.

Show comment
Hide comment
@sarahhodne

sarahhodne Dec 10, 2013

Contributor

Tags can also be created with the GitHub API. This still requires a token with write access to the repository, but one could also use a self-generated token from the ‘Account Settings’ on GitHub.

Contributor

sarahhodne commented Dec 10, 2013

Tags can also be created with the GitHub API. This still requires a token with write access to the repository, but one could also use a self-generated token from the ‘Account Settings’ on GitHub.

@wireframe

This comment has been minimized.

Show comment
Hide comment
@wireframe

wireframe Dec 10, 2013

@roidrage just my 2 cents, but as an active gem maintainer myself, I would greatly appreciate having travis (or any CI tool) automate the running of rake release which includes tagging the version in git as well as pushing to rubygems.

wireframe commented Dec 10, 2013

@roidrage just my 2 cents, but as an active gem maintainer myself, I would greatly appreciate having travis (or any CI tool) automate the running of rake release which includes tagging the version in git as well as pushing to rubygems.

@roidrage

This comment has been minimized.

Show comment
Hide comment
@roidrage

roidrage Dec 10, 2013

Member

@wireframe I think in that case, you'd be best off generating a temporary token with the GitHub API and use it to create the tag rather than utilize git to push it. You can use secure environment variables to store the token for your build.

Member

roidrage commented Dec 10, 2013

@wireframe I think in that case, you'd be best off generating a temporary token with the GitHub API and use it to create the tag rather than utilize git to push it. You can use secure environment variables to store the token for your build.

@roidrage

This comment has been minimized.

Show comment
Hide comment
@roidrage

roidrage May 1, 2014

Member

Given that there is a way to get this done, I'm closing this for now.

Member

roidrage commented May 1, 2014

Given that there is a way to get this done, I'm closing this for now.

@roidrage roidrage closed this May 1, 2014

@eddiejaoude

This comment has been minimized.

Show comment
Hide comment
@eddiejaoude

eddiejaoude May 16, 2014

Tag facility would be awesome 👍

eddiejaoude commented May 16, 2014

Tag facility would be awesome 👍

@sam-w

This comment has been minimized.

Show comment
Hide comment
@sam-w

sam-w Aug 5, 2014

Agreed - this would be an excellent feature: given how easy most other common tasks are in Travis, this is comparatively still too clunky. +1 for reopening.

sam-w commented Aug 5, 2014

Agreed - this would be an excellent feature: given how easy most other common tasks are in Travis, this is comparatively still too clunky. +1 for reopening.

@jburfield

This comment has been minimized.

Show comment
Hide comment
@jburfield

jburfield Sep 11, 2014

I'll put another +1 in here. Previously I used teamcity and had it tag green builds. Was very useful. I'm currently experimenting with the solution proposed by @wireframe but I'm seeing a bad side issue...

It seems pushing out the tag:

git push origin $GIT_TAG

Is triggering a build within Travis as travis is set to build on push.

This creates an infinite loop of builds...assuming they are not broken.

jburfield commented Sep 11, 2014

I'll put another +1 in here. Previously I used teamcity and had it tag green builds. Was very useful. I'm currently experimenting with the solution proposed by @wireframe but I'm seeing a bad side issue...

It seems pushing out the tag:

git push origin $GIT_TAG

Is triggering a build within Travis as travis is set to build on push.

This creates an infinite loop of builds...assuming they are not broken.

@wireframe

This comment has been minimized.

Show comment
Hide comment
@wireframe

wireframe Sep 15, 2014

@jburfield here's a config change to your .travis.yml so that buildtags will not be built:

branches:
  except:
    - /build-.+-\d{4}-\d{2}-\d{2}-.*/

wireframe commented Sep 15, 2014

@jburfield here's a config change to your .travis.yml so that buildtags will not be built:

branches:
  except:
    - /build-.+-\d{4}-\d{2}-\d{2}-.*/
@eddiejaoude

This comment has been minimized.

Show comment
Hide comment
@eddiejaoude

eddiejaoude Sep 15, 2014

Here is my example .travis.yml with tagging & not building tags - however it would be great to have the tagging & pushing built-in https://github.com/dev-confidence/example-backend-api/blob/master/.travis.yml

Tagging

after_success:
  # CREATE GIT TAG
  - git config --global user.email "builds@travis-ci.com"
  - git config --global user.name "Travis CI"
  - export GIT_TAG=build-$TRAVIS_BRANCH-$(date -u "+%Y-%m-%d")-$TRAVIS_BUILD_NUMBER
  - echo -n $GIT_TAG > public/version
  - git commit -m "Set build VERSION number" public/version
  - git tag $GIT_TAG -a -m "Generated tag from TravisCI build $TRAVIS_BUILD_NUMBER"
  - git push --quiet https://$GITHUBKEY@github.com/dev-confidence/example-backend-api $GIT_TAG > /dev/null 2>&1

Exclude:

branches:
  except:
    - /^build-[0-9a-z\-]*/

eddiejaoude commented Sep 15, 2014

Here is my example .travis.yml with tagging & not building tags - however it would be great to have the tagging & pushing built-in https://github.com/dev-confidence/example-backend-api/blob/master/.travis.yml

Tagging

after_success:
  # CREATE GIT TAG
  - git config --global user.email "builds@travis-ci.com"
  - git config --global user.name "Travis CI"
  - export GIT_TAG=build-$TRAVIS_BRANCH-$(date -u "+%Y-%m-%d")-$TRAVIS_BUILD_NUMBER
  - echo -n $GIT_TAG > public/version
  - git commit -m "Set build VERSION number" public/version
  - git tag $GIT_TAG -a -m "Generated tag from TravisCI build $TRAVIS_BUILD_NUMBER"
  - git push --quiet https://$GITHUBKEY@github.com/dev-confidence/example-backend-api $GIT_TAG > /dev/null 2>&1

Exclude:

branches:
  except:
    - /^build-[0-9a-z\-]*/
@mgk

This comment has been minimized.

Show comment
Hide comment
@mgk

mgk Feb 10, 2015

Any thoughts to re-opening this? I have used the manual method (thanks @wireframe). While workable, it is clunky and can easily cause an infinite build loop, as has been discussed.

Security note: the > /dev/null 2>&1 part of the the git push command is important. Without it your GH token can be exposed in the downloaded build log even though it is a hidden environment variable.

mgk commented Feb 10, 2015

Any thoughts to re-opening this? I have used the manual method (thanks @wireframe). While workable, it is clunky and can easily cause an infinite build loop, as has been discussed.

Security note: the > /dev/null 2>&1 part of the the git push command is important. Without it your GH token can be exposed in the downloaded build log even though it is a hidden environment variable.

@danielbodart

This comment has been minimized.

Show comment
Hide comment
@danielbodart

danielbodart May 15, 2015

Any chance this can be reopened? Seems a bit crazy to have Git Releases as a deploy stage that requires a Git Tag but no built in way to create the tag.

As Git Releases already has your token and is calling the GitHub API, you could very easily have a optional create tag flag and just call the tag API first before the release.

danielbodart commented May 15, 2015

Any chance this can be reopened? Seems a bit crazy to have Git Releases as a deploy stage that requires a Git Tag but no built in way to create the tag.

As Git Releases already has your token and is calling the GitHub API, you could very easily have a optional create tag flag and just call the tag API first before the release.

@stardust85

This comment has been minimized.

Show comment
Hide comment
@stardust85

stardust85 Jun 23, 2015

Please re-open this. Maybe this is a good candidate for an item on bountysource ;) People willing for this can bid for a pull request fixing this...

stardust85 commented Jun 23, 2015

Please re-open this. Maybe this is a good candidate for an item on bountysource ;) People willing for this can bid for a pull request fixing this...

@alxndrsn

This comment has been minimized.

Show comment
Hide comment
@alxndrsn

alxndrsn Jul 15, 2015

👍 this would be great

alxndrsn commented Jul 15, 2015

👍 this would be great

@pbek

This comment has been minimized.

Show comment
Hide comment
@pbek

pbek Jul 23, 2015

This would be really great!

pbek commented Jul 23, 2015

This would be really great!

@travis-ci travis-ci locked and limited conversation to collaborators Jul 23, 2015

@roidrage

This comment has been minimized.

Show comment
Hide comment
@roidrage

roidrage Jul 23, 2015

Member

Sorry, but this feature isn't on our immediate roadmap.

We'll update this ticket when we reconsider that in the future.

Member

roidrage commented Jul 23, 2015

Sorry, but this feature isn't on our immediate roadmap.

We'll update this ticket when we reconsider that in the future.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.