I am aiming to have three steps in my Travis flow:
- test (always)
- build (of docker image, only when a branch is merged into develop)
- deploy (same as build)
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.