Reputation: 57036
I am running on travis on 5 versions of nodeJS, .travis.yml is ....
language: node_js
node_js:
- 5.0
- 4.0
- 0.12.7
- 0.10.40
- 0.10.36
before_install:
- npm install -g grunt-cli
script:
- npm run travis
I want to set a travis environment variable for the run on nodeJS 5.0 only
something like this ...
language: node_js
node_js:
- 5.0
- env: POST_TO_COVERALLS=true
- 4.0
- 0.12.7
- 0.10.40
- 0.10.36
before_install:
- npm install -g grunt-cli
script:
- npm run travis
but this is invalid ... anyone know how to do this ...
1 - Preferably, via .travis.yml
2 - If not, through the travis web application
I KNOW HOW TO DO THIS VIA CODE - But can it be done through travis?
Thanks all
Upvotes: 2
Views: 4146
Reputation: 1364
Newly introduced Travis build stages combined with some YML inheritance and and some hacking around assigning the Bash variable can be very handy for this:
jobs:
include:
- stage: Tests
script: # run tests
- script: # run more tests
- &deploy-stuff
stage: Deploy
if: branch != master
env:
- ENV=$(if [ "$SOMETHING" = "thing" ]; then echo ${TRAVIS_BRANCH//\//-}; else echo "staging"; fi)
script: # do some things before deploy
deploy:
- provider: script
skip_cleanup: true
script: echo $ENV
on:
all_branches: true
condition: $TRAVIS_BRANCH = "devel" || $SOMETHING = "thing"
- <<: *deploy-stuff
if: branch = master
env:
- ENV="production"
deploy:
- provider: script
skip_cleanup: true
script: echo $ENV
on:
branch: master
Upvotes: 3
Reputation: 405
What about using the matrix to explicitly include the one "5.0" build where your environment variable is set to true (see documentation on explicitly including builds).
It would be something like the following
language: node_js
node_js:
- 4.0
- 0.12.7
- 0.10.40
- 0.10.36
env:
POST_TO_COVERALLS=false
matrix:
include:
- node_js: 5.0
env: POST_TO_COVERALLS=true
before_install:
- npm install -g grunt-cli
script:
- npm run travis
Upvotes: 2