hello-world-template issueshttps://code.axians.com/ci-cd-discovery/templates/hello-world-template/-/issues2020-12-01T16:52:46+01:00https://code.axians.com/ci-cd-discovery/templates/hello-world-template/-/issues/303-before-after2020-12-01T16:52:46+01:00Philippe Charrière03-before-afterYou can run a script **before** and **after** every `script` section of each job with these global keywords:
- `before_script`
- `after_script`
Ref: https://docs.gitlab.com/ee/ci/yaml/#global-keywords
### TODO
- [ ] create a merge req...You can run a script **before** and **after** every `script` section of each job with these global keywords:
- `before_script`
- `after_script`
Ref: https://docs.gitlab.com/ee/ci/yaml/#global-keywords
### TODO
- [ ] create a merge request from this issue
- [ ] open the WebIDE
- [ ] update the `.gitlab-ci.yml` file
- [ ] create a global `before_script` that prints `"Hello, I'm the before script"`
- [ ] create a global `after_script` that prints `"Bye, I'm the after script"`
- [ ] override `before_script` and `after_script` in the `hey` job:
- `before_script`: print `"Before hey job"`
- `after_script`: print `"After hey 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
```yaml
# syntax
before_script:
- foo
```
### Remarks
You can use `before_script` and `after_script` in a job to override the global commands for the current job.progresshttps://code.axians.com/ci-cd-discovery/templates/hello-world-template/-/issues/202-use-variables2020-12-01T16:52:39+01:00Philippe Charrière02-use-variablesYou 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
- [...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 named `song` with the value `"Jingle Bells"`
- second job `second_song` will have a variable named `song` with the value `"Let It Snow!"`
- each job will print `Happy Christmas!` followed by the name of its song
- [ ] 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
```yaml
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}"
```progresshttps://code.axians.com/ci-cd-discovery/templates/hello-world-template/-/issues/101-say-hello2020-12-01T17:51:41+01:00Philippe Charrière01-say-hello🖐️ This exercise is performed by the speakers and replayed by the learners, raise the hand if you have any question or if you need help
### TODO
- [ ] create a merge request from this issue
- [ ] open the WebIDE
- [ ] create a `.gitlab...🖐️ This exercise is performed by the speakers and replayed by the learners, raise the hand if you have any question or if you need help
### TODO
- [ ] create a merge request from this issue
- [ ] open the WebIDE
- [ ] create a `.gitlab-ci.yml` file
- [ ] add one stage: `greetings` to the `.gitlab-ci.yml` file
- [ ] add 2 jobs (belonging to `greetings`) to the `.gitlab-ci.yml` file
- `hello`, and this job will display "hello world!"
- `hey`, and this job will display "hey what's up?"
- [ ] 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)
| 🖐️🖐️🖐️ Information |
| ----------------- |
| We're going to use an **Axians Docker runner** tagged `docker`; so every job has to contain this: `tags: [docker]`|
### Help
This pipeline will display **"I'm walking"**
```yaml
stages:
- first_steps
walking:
stage: first_steps
tags: [docker]
script:
- echo "I'm walking"
```progress