TRAVIS_BUILD_STAGE_NAME not populated

Using this config

language: node_js
node_js:
  - 14

env:
  global:
    - MY_VAR=true

stages:
  - test

jobs:
  include:
    - stage: test
      script:
        - echo "MY_VAR is $MY_VAR"
        - echo "TRAVIS_BUILD_STAGE_NAME is $TRAVIS_BUILD_STAGE_NAME"

TRAVIS_BUILD_STAGE_NAME never gets populated. The output from the above is

MY_VAR is true
TRAVIS_BUILD_STAGE_NAME is 

Why isn’t the value test getting assigned to TRAVIS_BUILD_STAGE_NAME?

thanks!

Hello,

Just making sure, but I’m assuming you defined your environment variables prior to running this?

Just making sure, but I’m assuming you defined your environment variables prior to running this?

One shouldn’t have to define it. According to the docs:

The following default environment variables are available to all builds.

TRAVIS_BUILD_STAGE_NAME: The build stage. If a build does not use build stages, this variable is empty

Other default environment variables work as expected, ie TRAVIS_EVENT_TYPE, TRAVIS_BRANCH, etc.

Anyone? @Montana ? Thanks.

Hi everyone,

We’ve created a workaround that looks like this:

after_success: 
  - "[[ $TRAVIS_TEST_RESULT = 0 ]] && echo passed"
after_failure: 
  - "[[ $TRAVIS_TEST_RESULT = 1 ]] && echo failed"

So a working .travis.yml that we’ve tested is as follows:

os: linux
language: shell
install: skip

before_deploy:
  - if [[ $TRAVIS_TEST_RESULT == 1 ]]; then echo "exiting due to failed build"; sleep 2; exit 1; fi
deploy:
  provider: s3
  script: ./deploy.sh
  on:
    branch: minimal-build-check
  edge: true

jobs:
  include:
    - name: PASSING
      script:
        - sleep 2
    - name: FAILING
      script:
        - false

Make sure edge: true is present as this may curb any stashing issues you run into. Let me know if this works.

Cheers,
Montana

1 Like

yep this fixed it, thanks @montana

Hi @Montana I replied to this about a week ago but something triggered spam. Are you able to retrieve my reply so I can try again? No idea what triggered spam, and my issue isn’t resolved. Thank you!

You should be okay now.

Thanks. Can my original reply be retrieved?