Deployment incorrectly triggered (conditional not honored)

In the following job, deployment was triggered, despite it not meeting the conditions:

https://travis-ci.org/ExecutableBookProject/MyST-Parser/jobs/660218274/config?utm_medium=notification&utm_source=github_status

I have used this configuration for ages, so surely it is a change at your end?

deploy:
  - provider: pypi
    distributions: "sdist bdist_wheel"
    user: cjsewell
    password:
      secure: ...
    on:
      branch: master
      tags: true
      condition: $PYPI_DEPLOY = true

Most likely an issue arising from


which was later reverted by

If applicable, you can restart the affected build(s)/job(s).

I should mention that branch: master is redundant in the on key, because tags: true causes it to be ignored.

Yes that looks to have fixed it thanks. That PR really didn’t work out very well did it lol

Interestingly, I have a deploy block, just like described in the official documentation, which only ran for pushed tags in the past, but now it seems to be running for all changes on the main branch.

Code snippet and example of failing build:

  - stage: deploy
    python: 3.7
    env:
    install: skip
    script: skip
    deploy:
      provider: pypi
      distributions: sdist bdist_wheel
      user: ...
      password:
        secure: ...
      on:
        tags: true

P.S.: user: should also be exchanged by username:in the documentation according to the linter

This job ran before the revert. So, if you restart it, I believe you won’t see this problem.


Coincidentally, I should mention that, if the purpose of this deploy stage is to simply deploy the artifacts when tags: true condition is met, I suggest putting the entire stage in the conditional instead, so that a VM is not spun up only to do nothing.

- stage: deploy
  if: tag IS present
  ⋮

This is exactly the behavior I would expect from the on: tags: true directive. Why should I want to have Travis run the deploy build job when I won’t deploy anyway?

Apparently, it’s not possible to use the on: directive on entire build jobs. That should have the effect you suggest with if: tag IS present. The problem with if: is that it turns the declarative nature of the Travis CI configuration into a procedural one. That’s really a bad idea.

The if: thingy seems to be popular with GitHub Actions and Circle CI. But please, don’t do what they do wrong. Travis CI has been a role model in the past. You should know better. YAML should be declarative.

Imprint