我的目标是在Travis流程中有三个步骤:
我读过documentation on build stages and conditionals但我似乎误解了一些东西,因为Travis总是执行所有三个阶段(例如,当我推动一个功能分支时)。
我目前的设置如下:
jobs:
include:
- stage: test
script: ".travis/01-test.sh"
- stage: build
script: ".travis/02-build-and-push-image.sh"
if: (branch = develop) AND (NOT(type IN (push, pull_request)))
- stage: deploy
script: ".travis/03-deploy.sh staging"
if: (branch = develop) AND (NOT(type IN (push, pull_request)))
当我打开Travis构建页面上的配置选项卡时,我可以看到此配置,因此它不应该是解析错误。我也尝试分别列出工作和阶段,但结果是一样的:
jobs:
include:
- stage: test
script: ".travis/01-test.sh"
- stage: build
script: ".travis/02-build-and-push-image.sh"
- stage: deploy
script: ".travis/03-deploy.sh staging"
stages:
- test
- name: build
if: (branch = develop) AND (NOT(type IN (push, pull_request)))
- name: deploy
if: (branch = develop) AND (NOT(type IN (push, pull_request)))
我该如何使这项工作?我错过了什么吗?我知道构建阶段是测试版功能,但根据Travis blog post,我认为这应该已经有效了。
答案 0 :(得分:9)
我可以在内部解析条件时确认这是一个问题。
你可以尝试在" NOT"之后添加一个空格。运营商?如:
if: (branch = develop) AND (NOT (type IN (push, pull_request)))
这似乎解决了这个问题,我想知道Travis是否将not()视为一个函数(与env(foo)
一样),因此导致错误。