You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I use Travis Enterprise and am facing an issue when trying to run specific stages based on conditions.
What I want:
if the commit message contains the word #ci-test, run stages: build and test.
if a pull request is updated or created, run stages: build, test and deploy to dev.
if a push is made to the master branch, run stages: build, test and deploy to prod.
My (simplified) .travis.yml file is:
group: vmservices:
- dockergit:
depth: falseenv:
global:
- MYVAR="VARVALUE"jobs:
include:
- stage: "build"if: type = pull_request OR commit_message =~ /#ci-test/script: build_docker_image.sh
- stage: "tests"if: type = pull_request OR commit_message =~ /#ci-test/script: run_tests.sh
- stage: "deploy to dev"if: type = pull_requestscript: do_the_deploy_to_dev_magic.sh
- stage: "deploy to production"if: type = push AND branch = masterscript: do_the_deploy_to_prod_magic.sh
The problem is that it doesn't matter if #ci-test is present, or not, in the commit message, the build and tests stages are always run in any push, and are duplicated for pushes in PRs. I have made several tests with different checks, even using !~ instead of =~, but they always seem to be true.
I have also tested the travis-condition cli tool and the evals work as expected: returning false if the string is not present in the commit message and true if the string is present. But it doesn't seem to be this way in Travis.
An example of a test I have made:
I have a branch named test/ci-pull-triggers (wrote it wrong and didn't want to change it), that is not related to any pull requests. So, it should trigger only builds for pushes that contain #ci-test in them. With the .travis.yml above (slightly modified to run only tests), every push triggers a build in Travis.
A screenshot of details of one of the builds:
Note that the commit message wip: test build triggers v23 has no #ci-test in it.
The job config:
{"group": "vm","language": "python","services": ["docker"],"git": {"depth": false},"jobs": {"include": [{"stage": "Build docker image","if": "type = pull_request","script": [ HIDDEN ]},{"stage": "Run Tests","if": "type = pull_request OR commit_message =~ /#ci-test/","script": [ HIDDEN ]},{"stage": "Build and deploy to dev","if": "type = pull_request","script": [ HIDDEN ]},{"stage": "Build and deploy to production","if": "type = push AND branch = master","script": [ HIDDEN ]}]},"global_env": "HIDDEN","os": "linux","dist": "trusty","if": "type = pull_request OR commit_message =~ /#ci-test/","script": [ HIDDEN ],"stage": "Run Tests"}
Am I doing something wrong? Is Travis Enterprise using an old version of travis-condition? Is there something wrong with Travis conditions?
Thanks in advance.
The text was updated successfully, but these errors were encountered:
Hello.
I use Travis Enterprise and am facing an issue when trying to run specific stages based on conditions.
What I want:
#ci-test
, run stages:build
andtest
.build
,test
anddeploy to dev
.master
branch, run stages:build
,test
anddeploy to prod
.My (simplified)
.travis.yml
file is:The problem is that it doesn't matter if
#ci-test
is present, or not, in the commit message, thebuild
andtests
stages are always run in any push, and are duplicated for pushes in PRs. I have made several tests with different checks, even using!~
instead of=~
, but they always seem to betrue
.I have also tested the
travis-condition
cli tool and the evals work as expected: returningfalse
if the string is not present in the commit message andtrue
if the string is present. But it doesn't seem to be this way in Travis.An example of a test I have made:
I have a branch named
test/ci-pull-triggers
(wrote it wrong and didn't want to change it), that is not related to any pull requests. So, it should trigger only builds for pushes that contain#ci-test
in them. With the.travis.yml
above (slightly modified to run onlytests
), every push triggers a build in Travis.A screenshot of details of one of the builds:
Note that the commit message
wip: test build triggers v23
has no#ci-test
in it.The job config:
Am I doing something wrong? Is Travis Enterprise using an old version of
travis-condition
? Is there something wrong with Travis conditions?Thanks in advance.
The text was updated successfully, but these errors were encountered: