How can I pass value of variable from one job to next job in pipeline in GitLab CI?

Viewed 1136

Am I able to pass value from variable that I created in one job to next job so I can do some checks of that value in next job of the same stage ? I would like to have first job that creates some variable and then assigns value to that variable and next job, in same stage that would do check of that value ? I need this for specific use case in my pipeline ?

I was going through the documentation on GitLab and I couldn't find any recource that would help me with solving this case ?

Any help with this would be really appreciated. Thanks a lot! :)

1 Answers

Yes, you do this by using the dotenv file artifact. You'll create a file in one job that has a set of values in it like this:

FIRST_VAR=1234
SECOND_VAR=hello_world

Then set that as a dotenv type artifact according to the documentation, and that will make downstream jobs have those variables be set.

Related