shtravis-ci

Travis CI: env variable is empty when read from shell script


I have set some global variables in the Travis CI settings UI.

I've been trying to solve this on and off for a while, but if I recall correctly it stopped working in May this year (last time the pypi token was used).

When I try to echo the variable, I get an empty output: https://app.travis-ci.com/github/blockchain-certificates/cert-schema/jobs/627323874#L845-L846, and later https://app.travis-ci.com/github/blockchain-certificates/cert-schema/jobs/627323874#L855 twine fails as empty value are passed (this is not an issue in my local machine).

The variables are supposedly exported at the start of the build (https://app.travis-ci.com/github/blockchain-certificates/cert-schema/jobs/627323874#L180-L181), and I have just set the variables' name and value again in the settings, so I know for sure they are not empty there.

Here the script intent:

echo $TWINE_USERNAME
echo $TWINE_PASSWORD
twine upload dist/* -u $TWINE_USERNAME -p $TWINE_PASSWORD --verbose

And I have changed the execution of the script from sh to . as I read the context would be preserved, but to no avail.

Can someone help me there?


Solution

  • The issue was with semantic-release (python) which didn't handle Twine uploads anymore.

    I removed the the release-package script from semantic-release flow and added as an independent step after semantic-release version instruction.

    The script is now executed within the correct context and picks up global variables.