Setting conditionals in staging is not executed in travis

here snippet of my build for the .travis.yml file:

I’ve got a simple stage configuration

env:
  global:
    - BUILD_TYPE=demo
    - EXECUTABLE=false
if: env(EXECUTABLE) = false
jobs:
  include:
    - stage: stage_exec_1
      if: env(BUILD_TYPE) IN (dem, prod)
    - stage: stage_exec_3
      if: sender = lapots
    - stage: stage_not_exec
      if: (NOT branch = master

thank you for all help

So a few things I instantly see wrong in your .travis.yml.

To be clear, if: nor jobs: are valid values in .travis.yml (if you don’t believe me, try lint), so they’re just discarded, tossed essentially. Travis is pretty liberal about silently dropping hooks it doesn’t know what to do with unless you specify otherwise with a verbose tag.

Specifying behavior in env: is fine, but move the logic into a script: block and execute your if
statements there, or you could even theoretically run your if statements from a script that the .travis.yml calls, this would obviously be done using bash, so an example would be a file called:

deploy.sh

Make sure this is properly credentialed using chmod u+x. So there you have it, two ways you can properly do what you’re actually trying to do. I’m going to give you an article to read, I recommend reading it.

I recommend a bit more reading, but that should solve it for you.

1 Like
Imprint