Build Not Triggered With &&

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:

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

Converting it to this actually triggers the build:

-  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!

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

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.

1 Like

The imbalance was a mistake.

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