Ability to pass environment variables to later steps

Issue #15849 open
Vitalik Zaidman
created an issue

I wanted to break my pipelines into steps (including parallel) but each step runs separately and env variables are not shared between them, so 3 steps that configure them has to be repeated for each step right now.

I'd like to have a way to specify that i want to keep env variables from previous step just like we keep files using "artifacts".

Comments (4)

  1. Matt Ryall

    Interesting idea. Can you (or the other voters/watchers on this ticket) provide a specific example of something you want to pass between steps? Is it a version number or similar?

    If the values are static, you could configure them as an environment variable in your Pipelines configuration (via repository Settings > Pipelines > Environment variables), they will be available to each step in your pipeline.

    Obviously that won't work for values which come dynamically from your build, which is why I'm curious what exactly you want to pass through.

    Probably the best workaround for now is to write the values to a file, pass that file as an artifact, and source the file in the next step. Something like this:

        - step:
               - echo export VERSION=`generate-version.sh` >> build.env
               - build.env
        - step:
               - source build.env
               - echo "Building ${VERSION}..."

    I just tested this out, and it works reasonably well. Hopefully a good workaround until we can find time to add something more specific.

  2. Matt Ryall

    This issue came up in a discussion via email with a customer.

    In their situation, they would like to capture a version number and pass it to a later manual step, which would retrieve the tagged artifact and deploy it. These artifacts are stored indefinitely, so they would like to be able to do this even after the current 7-day limit on artifacts, which the above workaround won't help with. So we'd want to make sure that environment variables are stored in a way that we can keep them around indefinitely.

  3. Log in to comment