I am aiming to have three steps in my Travis flow:
I've read the documentation on build stages and conditionals but I seem to be misunderstanding something, as Travis ALWAYS executes all three stages (for example, when I push a feature branch).
My current setup is as follows:
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)))
I can see this config when I open the config tab on the Travis build page, so it shouldn't be a parsing error. I have also tried listing jobs and stages separately, but the result is the same:
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)))
How can I make this work? Am I missing something? I know build stages are a beta feature, but I'd assume this should work already, according to a Travis blog post.
I can confirm this is an issue while parsing the conditions internally.
Can you try adding a space after the "NOT" operator? As in:
if: (branch = develop) AND (NOT (type IN (push, pull_request)))
This seems to resolve the problem, I wonder if Travis is detecting not() as a function (as it does with env(foo)
), and therefore this is causing the error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With