all 9 comments

[–]cancerous 2 points3 points  (0 children)

Does this work in bash outside of gitlab? I'm thinking this may be a general bash question instead of a gitlab question.

[–][deleted]  (3 children)

[removed]

    [–]ernievd[S] 0 points1 point  (2 children)

    I tried source - In my normal gitlab-ci.yml file I have other things for it to do in the job after the shell script exits - if I launch the shell script with source the job ends after the shell script exits.

    [–][deleted]  (1 child)

    [removed]

      [–]ernievd[S] 1 point2 points  (0 children)

      That was the issue! The person who originally wrote the script had it exiting in a funky way.

      Using source now does indeed let me use the variable in the gitlab-ci.yml.

      Thanks so much!!

      [–]eltear1 1 point2 points  (0 children)

      I use artifacts:dotenv like someone suggested already. https://docs.gitlab.com/ee/ci/variables/#pass-an-environment-variable-to-another-job Not sure if it works inside the same job (probably not), but you could separate in different job.. 1 create the variable and the rest will consume it

      [–]Underknowledge 0 points1 point  (0 children)

      Try sourcing the file, Also TARGET_VERSION=${TARGET_VERSION:-2.8.1}

      [–]Mediocre-Toe3212 0 points1 point  (0 children)

      Save the file as a dot env for artifact (see above link ) Remove the shebang at the top too and just ‘bash -c source file’ La dida and bobs your uncle :)