3

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! :)

Milica Nikolić
  • 155
  • 2
  • 10

1 Answers1

3

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.

Patrick
  • 2,885
  • 1
  • 14
  • 20
  • Thank you for your answer! Is this solution applicable for the jobs in the same stage ? – Milica Nikolić Nov 29 '21 at 20:47
  • 2
    You would need to express a `needs` dependency between them to ensure that the job defining the artifact completed before the dependent job started, but it would work within the same stage otherwise, yes. – Patrick Nov 29 '21 at 21:20
  • Thanks for the help, I was able to solve the problem I had by following your instructions, plus I was able to refactor it to have less stages which is great ! :) – Milica Nikolić Dec 05 '21 at 14:11
  • Perfect! Don't forget to accept the answer if it solved your problem :) – Patrick Dec 05 '21 at 15:19