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

Trigger deployment on tag push not working #8518

Closed
ArtFlag opened this Issue Sep 29, 2017 · 5 comments

Comments

Projects
None yet
3 participants
@ArtFlag

ArtFlag commented Sep 29, 2017

Hi,

I'm trying to understand how to use the deploy section to release my software on GitHub.

I've spent hours figuring out why Travis won't trigger when I push a tag in order to deploy, or why pushing some commits then a tag still shows "Skipping a deployment with the releases provider because this is not a tagged commit"

Here is what I do:

  1. git commit some stuff
  2. git tag -a v1.0 -m "v1"
  3. git push (to master)
  4. git push --tags (to master too)

The build starts, tells me there is no tag (but Github shows my tag, so there is a tag).

.travis.yml:
language: python
branches:
  only:
  - master
python:
- '2.7'
before_install:
- if [ -z "$TRAVIS_TAG" ]; then exit 0; fi
- wget https://raw.githubusercontent.com/creationix/nvm/v0.31.0/nvm.sh -O ~/.nvm/nvm.sh
- source ~/.nvm/nvm.sh
- nvm install 5
- node --version
install:
- pip install -U pip
- pip install -r requirements.txt
- npm install -g grunt-cli
- npm install -g yarn
- npm install -g bower
- yarn add global ruby
- bower install
- gem install sass
script:
- grunt release
deploy:
  skip_cleanup: true
  provider: releases
  api_key:
    secure: ANIqYltOl+jdI
  file: $TRAVIS_BUILD_DIR/theme.tar.gz
  on:
    repo: repo/theme
    tags: true

What am I doing wrong?

I also tried pushing a tag only, it does not trigger the build.

I've noodled quite a bit with my tags (deleting them on the remote and locally, etc), not sure if that has any impact.

One extra question: if I have to push some commits and then push my tags, how does Travis know to stop the first build and start when the tags are pushed? I'm not sure I understand how to use this properly.

Thanks for any pointers.

(My repo is private, let me know if you need extra info on the commits)

@ArtFlag

This comment has been minimized.

Show comment
Hide comment
@ArtFlag

ArtFlag Oct 2, 2017

Ok, long story short: RTFM.

A build can be triggered via simple tag push.
In this case, the branch name is the tag name.
Therefore Branch.only.master will never work.

Solution: add a regexp to the branch.only array that matches the tags you want to build.

language: python
branches:
  only:
  - master
  - /^v.*$/
python:
- '2.7'
before_install:
- if [ -z "$TRAVIS_TAG" ]; then exit 0; fi
- wget https://raw.githubusercontent.com/creationix/nvm/v0.31.0/nvm.sh -O ~/.nvm/nvm.sh
- source ~/.nvm/nvm.sh
- nvm install 5
- node --version
install:
- pip install -U pip
- pip install -r requirements.txt
- npm install -g grunt-cli
- npm install -g yarn
- npm install -g bower
- yarn add global ruby
- bower install
- gem install sass
script:
- grunt release
deploy:
  skip_cleanup: true
  provider: releases
  api_key:
    secure: ANIqYltOl
  file: $TRAVIS_BUILD_DIR/theme.tar.gz
  on:
    repo: repo/theme
    tags: true

ArtFlag commented Oct 2, 2017

Ok, long story short: RTFM.

A build can be triggered via simple tag push.
In this case, the branch name is the tag name.
Therefore Branch.only.master will never work.

Solution: add a regexp to the branch.only array that matches the tags you want to build.

language: python
branches:
  only:
  - master
  - /^v.*$/
python:
- '2.7'
before_install:
- if [ -z "$TRAVIS_TAG" ]; then exit 0; fi
- wget https://raw.githubusercontent.com/creationix/nvm/v0.31.0/nvm.sh -O ~/.nvm/nvm.sh
- source ~/.nvm/nvm.sh
- nvm install 5
- node --version
install:
- pip install -U pip
- pip install -r requirements.txt
- npm install -g grunt-cli
- npm install -g yarn
- npm install -g bower
- yarn add global ruby
- bower install
- gem install sass
script:
- grunt release
deploy:
  skip_cleanup: true
  provider: releases
  api_key:
    secure: ANIqYltOl
  file: $TRAVIS_BUILD_DIR/theme.tar.gz
  on:
    repo: repo/theme
    tags: true

@ArtFlag ArtFlag closed this Oct 2, 2017

@zpydee

This comment has been minimized.

Show comment
Hide comment
@zpydee

zpydee Nov 2, 2017

@ArtFlag thanks for your comment, however the FMs ain't so obvious.

zpydee commented Nov 2, 2017

@ArtFlag thanks for your comment, however the FMs ain't so obvious.

@ArtFlag

This comment has been minimized.

Show comment
Hide comment
@ArtFlag

ArtFlag Nov 2, 2017

I know, it took me a while to go through different pages and patch the pieces together to realise my mistake.
I hope this issue will help others in the same situation.
I also updated the docs to talk about the branches.only property in the releases page.

There's a few gotchas here and there with Travis, but it's still worth the pain 😉

ArtFlag commented Nov 2, 2017

I know, it took me a while to go through different pages and patch the pieces together to realise my mistake.
I hope this issue will help others in the same situation.
I also updated the docs to talk about the branches.only property in the releases page.

There's a few gotchas here and there with Travis, but it's still worth the pain 😉

@madcowswe

This comment has been minimized.

Show comment
Hide comment
@madcowswe

madcowswe Mar 27, 2018

Thanks for noting the solution, indeed it wasn't obvious. Cheers!

madcowswe commented Mar 27, 2018

Thanks for noting the solution, indeed it wasn't obvious. Cheers!

@zpydee

This comment has been minimized.

Show comment
Hide comment
@zpydee

zpydee Mar 28, 2018

@ArtFlag to be honest, moving to gitlab solved this and so many other problems for me. ihmo, its far superior as a product.

zpydee commented Mar 28, 2018

@ArtFlag to be honest, moving to gitlab solved this and so many other problems for me. ihmo, its far superior as a product.

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