我的Travis文件包含两个阶段:
test
,可为多个Node.js版本运行构建/测试(并且可以运行)deploy
,当满足以下条件时,它将运行生成并将代码部署到npm:branch = master AND tag IS present AND type = push
我向主服务器推送了tagged commit(因此应满足所有三个条件),但是在test
阶段成功完成之后,deploy
阶段is not started。 / p>
这是我的.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
答案 0 :(得分: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