Build Not Triggered With &&


#1

Hello I’ve run into an issue using conditionals. Using echo hi is an example.

Adding this to my .travis.yml stops the build from triggering on GitHub:

install:
-  [[ $TRAVIS_PYTHON_VERSION == "3.4" ]] && echo hi

Converting it to this actually triggers the build:

install:
-  if [[ $TRAVIS_PYTHON_VERSION == "3.4" ]]; then echo hi; fi

[ $TRAVIS_PYTHON_VERSION == "3.4" ]] && echo hi works perfectly fine outside of Travis, is there an issue with what I’m doing or is this a bug? Thanks!


#2

& is a special character in YAML (which introduces the anchor name), so you can’t use it bare.

https://learnxinyminutes.com/docs/yaml/

Also, your square brackets do not balance. Are you sure it is working as intended?

install: '[ $TRAVIS_PYTHON_VERSION == "3.4" ] && echo hi'

should work.


#3

The imbalance was a mistake.

The & being a special character makes sense, thanks for the fix! I’ll try it out.