Multiple OR conditions doesn't work

It seems that my conditional doesn’t work. I can’t figure out why it isn’t the case. Here is my build https://travis-ci.com/github/KyberNetwork/KyberSwap/jobs/400038750

    - stage: deploy to user-dashboard
      deploy:
        - provider: script
          script: bash .travis/awx_job_launch.sh $TRAVIS_BRANCH
      if: branch = develop OR branch = staging OR branch = master

Changing to this

    - stage: deploy to user-dashboard
      deploy:
        - provider: script
          script: bash .travis/awx_job_launch.sh $TRAVIS_BRANCH
          on:
            all_branches: true
            condition: $TRAVIS_BRANCH =~ ^develop|staging|master$

And it worked: https://travis-ci.com/github/KyberNetwork/KyberSwap/jobs/400057922

1 Like

Hello,

Could you please try with the parenthesis as follows and see if that works?

condition: $TRAVIS_BRANCH =~ ^(develop|staging|master)$

Do you mean changing:

    - stage: deploy to user-dashboard
      deploy:
        - provider: script
          script: bash .travis/awx_job_launch.sh $TRAVIS_BRANCH
      if: branch = develop OR branch = staging OR branch = master

to

    - stage: deploy to user-dashboard
      deploy:
        - provider: script
          script: bash .travis/awx_job_launch.sh $TRAVIS_BRANCH
      condition: $TRAVIS_BRANCH =~ ^(develop|staging|master)$

Please try as below;

- stage: deploy to user-dashboard
  deploy:
    - provider: script
      script: bash .travis/awx_job_launch.sh $TRAVIS_BRANCH
      on:
        all_branches: true
        condition: $TRAVIS_BRANCH =~ ^(develop|staging|master)$

Sorry if I’m not clear about my question. My question is why this config did NOT work:

- stage: deploy to user-dashboard
      deploy:
        - provider: script
          script: bash .travis/awx_job_launch.sh $TRAVIS_BRANCH
      if: branch = develop OR branch = staging OR branch = master

The other config with condition: $TRAVIS_BRANCH =~ ^develop|staging|master$ did work perfectly.

Please see our documentation, how you can apply the conditions on your deploy phase;

Your expected config may not work with deploy but can work with conditions on jobs.

Thanks.

Imprint