travis-cifile-sharing

Pass information between stages in travis-ci


I would like to use the free online service transfer.sh for sharing build artifacts between stages in travis ci. While uploading/downloading is easy, the problem is that the resulting URL contains a non-predictable part and hence, the whole URL becomes non-predictable.

When uploading artifacts in an early stage, I need to pass the resulting URLs to later stages. AFAIK, jobs in a multi-stage build are strictly isolated from each other.


Solution

  • [EDIT] I just noticed that Travis introduced a feature called workspaces which is exactly what I wanted. No need for above workaround.


    I found a solution for passing artifacts between build stages on Travis-CI: Abuse github releases.

    1. Create a tag in the github repo, e.g. "travis-ci"
    2. In the .travis.yml, set TRAVIS_TAG=travis-ci.
    3. Add a deployment (deploy to github) step to the stages that need to store artifacts. Create and use an encrypted github token for authentication. That works even on Windows hosts which have secret environment variables disabled. This step needs the TRAVIS_TAG because otherwise it will create a new tag which we don't want.
    4. Include the current TRAVIS_BUILD_NUMBER in each file name
    5. In a later stage, use to curl to download the artifact, because the URL is now predictable.

    When building a tag, one could omit overriding TRAVIS_TAG and use that particular tag for storing intermediate artifacts. One could then remove them later manually.