Question

I want to use environment variables/matrix to test my repo in 2 different builds.

I have a gruntfile with 2 tasks and I would like to make a BUILD env variable like this:

  - grunt --verbose $BUILD:travis 

where the $BUILD would be alternativly nocompat or default.
What am I doing wrong?

My .travis.yml file:

language: node_js

node_js:
- 0.11

env:
  - BUILD='nocompat'
  - BUILD='default'

before_script:
    - npm install grunt-cli -g
    - curl https://gist.github.com/santiycr/5139565/raw/sauce_connect_setup.sh | bash

script:
  - grunt --verbose $BUILD:travis
Était-ce utile?

La solution

Based on irc conversation it looks like there are extra settings in the .travis.yml that are conflicting with this.

For example, given a .travis.yml that looks like this:

language: node_js

node_js:
- 0.11

env:
  matrix:
    - BUILD='nocompat'
    - BUILD='default'

env:
  global:
    - SAUCE_USERNAME=....
    - SAUCE_ACCESS_KEY=....

before_script:
    - npm install grunt-cli -g
    - curl https://gist.github.com/santiycr/5139565/raw/sauce_connect_setup.sh | bash

script:
  - grunt --verbose $BUILD:travis

You actually need:

language: node_js

node_js:
- 0.11

env:
  matrix:
    - BUILD='nocompat'
    - BUILD='default'

  global:
    - SAUCE_USERNAME=....
    - SAUCE_ACCESS_KEY=....

before_script:
    - npm install grunt-cli -g
    - curl https://gist.github.com/santiycr/5139565/raw/sauce_connect_setup.sh | bash

script:
  - grunt --verbose $BUILD:travis

If you imagine YAML as JS what you were doing before was this:

config = {};
config.env = {'matrix': ...};
config.env = {'global': ...};

The global setting was hiding the matrix setting.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top