在非标记构建的Travis.CI构建矩阵中排除作业

时间:2015-08-06 23:26:52

标签: travis-ci

我有一个看似正常的Travis.CI构建矩阵,我正在使用部署到Github Releases。我的矩阵中有一个额外的元素,用于构建和打包源包,我只想在推送标签时构建它。

当构建不是标记构建时,有没有办法跳过构建矩阵中的构建?

我尝试过这样的东西,但它没有用。它仍然每次构建源,这是多余的。

matrix:
 include:
  - os: linux
    env: DEPLOY=binary
  - os: osx
    env: DEPLOY=binary
  - os: linux
    env: DEPLOY=source
    on:
      tags: true       # <- try and skip this job for non-tag builds (doesn't work!)

[...]

deploy:
  provider: releases
  on:
    tags: true

2 个答案:

答案 0 :(得分:4)

不幸的是,由于构建矩阵的方式,目前无法实现。我能想到的唯一解决方案是检查您想要跳过的作业中的TRAVIS_TAG环境变量,而不是在那里运行测试。我知道这有一些缺点,因为我们仍然会创建和运行构建,但至少它会很快。

答案 1 :(得分:0)

我知道这是很久以前的事了,但为了将来参考,它对我有用:if: tag IS present。所以您的矩阵将是:

matrix:
 include:
  - os: linux
    env: DEPLOY=binary
  - os: osx
    env: DEPLOY=binary
  - os: linux
    env: DEPLOY=source
    if: tag IS present
相关问题