Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to print to console in Travis CI

I'm trying to print some information using echo in my .travis.yml file, but I don't see anything in the log.

My .travis.yml file:

before_install:
  - echo $TRAVIS_COMMIT
  - echo $TRAVIS_TAG
  - echo $TRAVIS_BRANCH
  - echo $TRAVIS_BUILD_NUMBER
  - echo $TRAVIS_REPO_SLUG

My output:

enter image description here

like image 357
Derek Soike Avatar asked Sep 21 '17 23:09

Derek Soike


2 Answers

Travis CI collapses the output for each phase except for the script phase.

If you print to the console with echo in the script phase, your output will be displayed.

If you print to the console in any other phase, you will need to expand the output for that phase to see your content.


Using this .travis.yml config:

script:
  - echo $TRAVIS_COMMIT
  - echo $TRAVIS_TAG
  - echo $TRAVIS_BRANCH
  - echo $TRAVIS_BUILD_NUMBER
  - echo $TRAVIS_REPO_SLUG

Yields this output:

enter image description here

like image 163
Derek Soike Avatar answered Jan 13 '23 06:01

Derek Soike


Similarly to this SO question, you have to click the arrow on the left to see the output.

Check out this answer from the other question: useful image from the other answer

like image 30
ajaugust44 Avatar answered Jan 13 '23 06:01

ajaugust44