Travis-CI skipping deployment although Commit is tagged

五迷三道 提交于 2019-12-04 00:41:54

You need to remove

branches:
    only:
    - master

See https://github.com/travis-ci/travis-ci/issues/2498#issuecomment-48337712

I realize this is a bummer, but I am not sure that Travis can be configured in the way you desire. You may want to open a ticket - https://github.com/travis-ci/travis-ci/issues/new

UPDATE:

Use a regex for the tags in branches.only:

branches:
    only:
    - master
    - /v\d+\.\d+[a-z]/

Travis CI differentiate between builds initiated by pushing a commit or pull request and builds initiated by pushing a tag.

TRAVIS_BRANCH: for push builds, or builds not triggered by a pull request, this is the name of the branch. for builds triggered by a pull request this is the name of the branch targeted by the pull request. for builds triggered by a tag, this is the same as the name of the tag (TRAVIS_TAG).

Source: https://docs.travis-ci.com/user/environment-variables/

So when pushing a commit with a tag this will trigger two builds with different conditions. If you only filter your branch names, the build for the tag won't get triggered!

One option beside using a regex inside your branch condition is to switch to conditional builds and stages (Conditions documentation: https://docs.travis-ci.com/user/conditions-v1). You can then do something like this:

stages:
- name: Run tests and build
  if: branch IN (develop, master)
- name: Build and deploy release
  if: tag IS present
jobs:
  include:
  - stage: Build debug
    ...
    script: ...
  - stage: Build and deploy release on tags
    ...
    deploy: ...

Here is my complete example travis.yml with conditional stages: https://travis-ci.com/G00fY2/android-ci-testproject/jobs/205348876/config

kenorb

Apart of what @Spain said about removing branches section (this is required, because the tag build won't be invoked), you need to make sure you've pushed the tags (git push origin --tags) so the tag exist on the remote.

The deployment of release will happen only for a tagged commit, not for any other branch to avoid publishing the same files multiple times. The released tag will show under Active Branches in Travis CI and its build will trigger the release, so you should see the output like:

Fetching: dpl-1.8.14.gem (100%)
Successfully installed dpl-1.8.14
Installing deploy dependencies
dpl.2
Preparing deploy
Logged in as X
Deploying to repo: FOO/BAR
Current tag is: FOOBAR-2015
dpl.3
Deploying application

After successful build, you should see the files on GitHub under Releases tab.


Please check: GitHub Releases Uploading at Travis CI for further info.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!