Let’s say your TravisCI file is cluttering up due to having too many shell / bash commands in the “.travis.yml” file and you’ve decided to move the commands out to a separate shell script. Now, you’ll want to get export/return data out from this script but you don’t know how. There are two ways to approach this.
If your bash script is only expected to return one value, then you may want to call it from the TravisCI yaml file this way:
script: - export ENDPOINT=$(bash discover_service.sh);
And you’ll want to add this to the bash script you’re calling (exit returns the variable to whatever’s calling it):
if [ $TRAVIS_BRANCH == 'master' ]; then exit $ENDPOINT else exit $ENDPOINT fi
However, if your bash script sets multiple variables or is expected to generate a lot of data, you could “source” it from the TravisCI yaml file this way:
script: - . ./deploy.sh
I hope that was helpful!