Travis部署阶段没有运行条件if:branch = master AND tag IS present AND type = push

问题描述 投票:0回答:1

我的Travis文件包含两个阶段:

  • test,运行多个Node.js版本的构建/测试(并且工作)
  • deploy,当满足以下条件时,应运行构建并将代码部署到npm:branch = master AND tag IS present AND type = push

我把tagged commit推向了主人(因此应该满足所有三个条件),但是在test阶段成功完成后,deploy阶段is not started

以下是我的.travis.yml file的其他(可能很重要)部分:

language: node_js

node_js:
  - '8'
  - '9'
  - '10'
  #- '11' # Runs the coverage report (added below)

before_script: npm run build
script:
  - npm run lint
  - npm run coverage

jobs:
  include:
    - stage: test
      node_js: '11'
      after_success: 'cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js'
    - stage: deploy
      node_js: '11'
      script: skip
      deploy:
        provider: npm
        # ...

stages:
  - test
  - name: deploy
    if: branch = master AND tag IS present AND type = push
node.js npm travis-ci
1个回答
0
投票

将这些行添加到我的travis文件后,我发现了自己:

echo "$TRAVIS_EVENT_TYPE" # result: push
echo "$TRAVIS_TAG"        # result: v0.14.0
echo "$TRAVIS_BRANCH"     # result: v0.14.0

因此,当设置标记时,分支将设置为标记名称。我也在docs for environment variables上发现了这个暗示:

请注意,对于标记,git不存储标记提交的分支。

奇怪的是,您仍然可以在部署条件中检查分支。所以这对我有用:

  # ...
  deploy:
    provider: npm
    # ...
    on:
      tags: true
      branch: master

stages:
  - test
  - name: deploy
    if: type = push
© www.soinside.com 2019 - 2024. All rights reserved.