I have jobs triggered by commits to master (https://travis-ci.com/geerlingguy/ansible-collection-php_roles/jobs/296104246) as well as triggered by cron scheduled builds (https://travis-ci.com/geerlingguy/ansible-collection-php_roles/jobs/296088189#L488) that started failing within the past day or two because the deploy stage is being run when it should not. I have it configured to only run on tags: https://github.com/geerlingguy/ansible-collection-php_roles/blob/master/.travis.yml#L30-L35
deploy:
provider: script
script: ansible-playbook -i 'localhost,' scripts/deploy.yml -e "tag=$TRAVIS_TAG"
on:
tags: true
condition: $DISTRO = centos7
For the past week this has run on a daily schedule with no problem (see past builds here: https://travis-ci.com/geerlingguy/ansible-collection-php_roles/builds)… it seems the problem only started occurring in the past day or two. Did something change with the deploy on conditions?
Indeed, this should be a duplicate.
https://travis-ci.com/rubencabrera/odoo-docker/builds/144181440
I have a deploy stage set up like:
jobs:
include:
[other stages]
- stage: deploy
on:
tags: true
provider: script
script:
- "./.travis/docker_push.bash"
skip_cleanup: true
This stage was running on commits that didn’t have a tag created by the previous stage. You can see on the link that I changed to using the $TRAVIS_TAG env variable, but it fails. What am I misunderstanding here?
on: is only valid for, and located under, the deploy: clause. And it only sets a condition for a specific deployment in the deploy phase, not for the entire job.
If you need to run an entire job conditionally, use if: as per Conditional Builds, Stages and Jobs - Travis CI.
The condition to define a stage is explained in
What you need is:
jobs:
include:
- stage: deploy
if: tag IS present
# ⋮
Thank you very much, I was carrying this bit from another CI yaml and assumed it worked the same way.