如何在travis.yml中有条件地设置变量?

时间:2019-08-24 13:31:52

标签: travis-ci

在这种情况下,我在GitHub存储库上有分支,我希望将它们作为带有各自分支名称的带标签npm包推送。但不是大师。

jobs:
  include:
    - stage: test
      script: npm run release:ci
      deploy:
        provider: npm
        email: $NPM_EMAIL
        api_key: $NPM_TOKEN
        skip_cleanup: true
        tag: dt
        on:
          all_branches: true
      after_deploy: npm run release:ci:dt
    - stage: deploy
      deploy:
        provider: npm
        email: $NPM_EMAIL
        api_key: $NPM_TOKEN
        tag: $TRAVIS_BRANCH
        # ^^^ If master, no tag
        skip_cleanup: true
        on:
          all_branches: true

我想知道是否可以在if: branch != master下添加tag,以便仅对非主分支启用该功能吗?

而且,出于一般目的,是否可以将bash脚本分配给变量?

# is it possible to do this?
tag: "if [ $TRAVIS_BRANCH == "master" ]; then ""; else $TRAVIS_BRANCH; fi"

0 个答案:

没有答案