02-use-variables
You can use environment variables inside the .gitlab-ci.yml
file for the whole pipeline or specifically for a job.
TODO
-
create a merge request from this issue -
open the WebIDE -
update the .gitlab-ci.yml
file -
The 2 messages "hello world!"
and"hey what's up?"
should be defined in variables (inside each jobs) -
Add a second stage named christmas_songs
-
Add a global variable (visible for the whole pipeline) named message
with this value"Happy Christmas!"
-
Add 2 new jobs belonging to the christmas_songs
stage:- first job
first_song
will have a variable namedsong
with the value"Jingle Bells"
- second job
second_song
will have a variable namedsong
with the value"Let It Snow!"
- each job will print
Happy Christmas!
followed by the name of its song
- first job
-
commit your changes, it will trigger the pipeline -
observe the pipeline -
observe the output of the pipeline -
merge on master (the pipe will be triggered again)
Help
The script below will display "I'm walking" and "I'm running", but in 2 different stages
stages:
- first_steps
- a_little_further
variables:
who: "I'm"
walking:
stage: first_steps
tags: [docker]
variables:
action: "walking"
script:
- echo "${who} ${action}"
running:
stage: a_little_further
tags: [docker]
variables:
action: "running"
script:
- echo "${who} ${action}"