Skip to content

Commit f699a36

Browse files
committed
Final slides for 20231114
1 parent 4673cbb commit f699a36

File tree

23 files changed

+204
-42
lines changed

23 files changed

+204
-42
lines changed

160_gitlab_ci/000_rollout/bootstrap.sh

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ if test -f .env; then
1111
fi
1212

1313
export GIT_USER=seat
14-
export GIT_EMAIL="seat@seat${SEAT_INDEX}.inmylab.de"
15-
export GIT_CRED="https://seat:${SEAT_PASS}@gitlab.seat${SEAT_INDEX}.inmylab.de"
14+
export GIT_EMAIL="seat@seat${SEAT_INDEX}.${DOMAIN}"
15+
export GIT_CRED="https://seat:${SEAT_PASS}@gitlab.seat${SEAT_INDEX}.${DOMAIN}"
1616

1717
echo
1818
echo "### Removing previous deployment on seat ${SEAT_INDEX}"
@@ -145,17 +145,17 @@ if ! docker compose exec -T gitlab \
145145
echo "done."
146146
fi
147147
git config --global user.name "seat"
148-
git config --global user.email "seat@seat${SEAT_INDEX}.inmylab.de"
148+
git config --global user.email "seat@seat${SEAT_INDEX}.${DOMAIN}"
149149
git config --global credential.helper store
150-
echo "https://seat:${SEAT_PASS}@gitlab.seat${SEAT_INDEX}.inmylab.de" >"${HOME}/.git-credentials"
150+
echo "https://seat:${SEAT_PASS}@gitlab.seat${SEAT_INDEX}.${DOMAIN}" >"${HOME}/.git-credentials"
151151
if test -d /tmp/demo; then
152152
rm -rf /tmp/demo
153153
fi
154154
(
155155
mkdir -p /tmp/demo
156156
cd /tmp/demo
157157
git clone https://github.com/nicholasdille/container-slides .
158-
git remote add downstream "https://gitlab.seat${SEAT_INDEX}.inmylab.de/seat/demo"
158+
git remote add downstream "https://gitlab.seat${SEAT_INDEX}.${DOMAIN}/seat/demo"
159159
CURRENT_BRANCH="$(git branch --show-current)"
160160
git branch --remotes --list \
161161
| grep -v downstream \
@@ -188,7 +188,7 @@ echo
188188
echo "### Retrieving runner registration token on seat ${SEAT_INDEX}"
189189
export REGISTRATION_TOKEN="$(
190190
curl \
191-
--url "https://gitlab.seat${SEAT_INDEX}/api/v4/user/runners" \
191+
--url "https://gitlab.seat${SEAT_INDEX}.${DOMAIN}/api/v4/user/runners" \
192192
--silent \
193193
--show-error \
194194
--request POST \

160_gitlab_ci/000_rollout/compose.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,10 @@ services:
217217
traefik.http.routers.registry-s.service: registry
218218
traefik.http.routers.registry-s.tls: "true"
219219
# SSH: service port
220-
traefik.tcp.services.ssh.loadbalancer.server.port: 2222
220+
traefik.tcp.services.ssh.loadbalancer.server.port: 22
221221
# SSH: TLS passthrough
222222
traefik.tcp.routers.ssh.entrypoints: ssh
223-
traefik.tcp.routers.ssh.rule: HostSNI(`gitlab.${DOMAIN:?You must supply DOMAIN}`)
223+
traefik.tcp.routers.ssh.rule: HostSNI(`*`)
224224
traefik.tcp.routers.ssh.service: ssh
225225
traefik.tcp.routers.ssh.tls.passthrough: "true"
226226

160_gitlab_ci/010_jobs_and_stages/slides.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ docker run --interactive --tty --rm \
121121
1. Add files to root of project:
122122

123123
```bash
124-
git checkout 160_gitlab_ci/010_jobs_and_stages/build -- '*'
124+
git checkout origin/160_gitlab_ci/010_jobs_and_stages/build -- '*'
125125
```
126126
<!-- .element: style="width: 40em;" -->
127127

@@ -136,7 +136,7 @@ docker run --interactive --tty --rm \
136136
1. Add `lint/.gitlab-ci.yml` to root of project:
137137

138138
```bash
139-
git checkout 160_gitlab_ci/010_jobs_and_stages/lint -- '*'
139+
git checkout origin/160_gitlab_ci/010_jobs_and_stages/lint -- '*'
140140
```
141141
<!-- .element: style="width: 40em;" -->
142142

@@ -151,7 +151,7 @@ docker run --interactive --tty --rm \
151151
1. Add `parallel/.gitlab-ci.yml` to root of project:
152152

153153
```bash
154-
git checkout 160_gitlab_ci/010_jobs_and_stages/parallel -- '*'
154+
git checkout origin/160_gitlab_ci/010_jobs_and_stages/parallel -- '*'
155155
```
156156
<!-- .element: style="width: 40em;" -->
157157

160_gitlab_ci/020_variables/ci.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ Available in project-, group- and instance-level
1010

1111
Careful with protected variables
1212

13+
Loops are detected, e.g. `FOO=$BAR` and `BAR=$FOO`
14+
1315
---
1416

1517
## Hands-On [<i class="fa fa-comment-code"></i>](https://github.com/nicholasdille/container-slides/tree/160_gitlab_ci/020_variables/ci "020_variables/ci")
@@ -32,7 +34,7 @@ Careful with protected variables
3234
1. Fetch change:
3335

3436
```bash
35-
git checkout 160_gitlab_ci/020_variables/ci -- '*'
37+
git checkout origin/160_gitlab_ci/020_variables/ci -- '*'
3638
```
3739
<!-- .element: style="width: 47em;" -->
3840

160_gitlab_ci/020_variables/predefined.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Some help interacting with the GitLab server
1515
1. Remove `variables` directive
1616

1717
```bash
18-
git checkout 160_gitlab_ci/020_variables/predefined -- '*'
18+
git checkout origin/160_gitlab_ci/020_variables/predefined -- '*'
1919
```
2020
<!-- .element: style="width: 35em;" -->
2121

160_gitlab_ci/020_variables/slides.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Variables [](https://docs.gitlab.com/ee/ci/yaml/#variables) can be...
2121
1. Update files:
2222

2323
```yaml
24-
git checkout 160_gitlab_ci/020_variables/inline -- '*'
24+
git checkout origin/160_gitlab_ci/020_variables/inline -- '*'
2525
```
2626
<!-- .element: style="width: 40em;" -->
2727

160_gitlab_ci/030_script_blocks/slides.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ job_name:
3333
3434
`after_script` runs even if the job failed (useful for cleanup)
3535

36+
Beware of collapsed multi-line commands in the job log
37+
3638
---
3739

3840
## Hands-On [<i class="fa fa-comment-code"></i>](https://github.com/nicholasdille/container-slides/tree/160_gitlab_ci/030_script_blocks "030_script_blocks")
@@ -48,7 +50,7 @@ Move `apk` operations into `before_script`
4850
See new `.gitlab-ci.yml`:
4951

5052
```bash
51-
git checkout 160_gitlab_ci/030_script_blocks -- '*'
53+
git checkout origin/160_gitlab_ci/030_script_blocks -- '*'
5254
```
5355

5456
Yes, this is still repetetive <i class="fa-duotone fa-face-smile-tongue fa-duotone-colors"></i>

160_gitlab_ci/040_image/slides.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ Do not use community images
1818

1919
Avoid maintaining custom image
2020

21+
### Image allowlist
22+
23+
XXX [](https://docs.gitlab.com/runner/executors/kubernetes.html#restrict-docker-images-and-services)
24+
2125
---
2226

2327
## Hands-On [<i class="fa fa-comment-code"></i>](https://github.com/nicholasdille/container-slides/tree/160_gitlab_ci/040_image "040_image")
@@ -30,5 +34,5 @@ Use `image` instead of `before_script`
3034
See new `.gitlab-ci.yml`:
3135

3236
```bash
33-
git checkout 160_gitlab_ci/040_image -- '*'
37+
git checkout origin/160_gitlab_ci/040_image -- '*'
3438
```

160_gitlab_ci/050_defaults/slides.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,13 @@ Apply settings to all jobs using `default` [](https://docs.gitlab.com/ee/ci/yaml
1717
- `after_script`
1818
- and some more we will explore later <i class="fa-duotone fa-face-smile-halo fa-duotone-colors"></i>
1919

20+
### Global variables
21+
22+
XXX separate field `variables`
23+
2024
---
2125

22-
## Hands-On [<i class="fa fa-comment-code"></i>]https://github.com/nicholasdille/container-slides/tree/160_gitlab_ci/050_default "050_default")
26+
## Hands-On [<i class="fa fa-comment-code"></i>](https://github.com/nicholasdille/container-slides/tree/160_gitlab_ci/050_default "050_default")
2327

2428
1. Add `default` for `image`
2529
1. Remove `image` from all jobs
@@ -28,5 +32,5 @@ Apply settings to all jobs using `default` [](https://docs.gitlab.com/ee/ci/yaml
2832
See new `.gitlab-ci.yml`:
2933

3034
```bash
31-
git checkout 160_gitlab_ci/050_default -- '*'
35+
git checkout origin/160_gitlab_ci/050_default -- '*'
3236
```

160_gitlab_ci/060_artifacts/slides.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ Add untracked files
2828

2929
`artifacts` can be in `default` [<i class="fa-solid fa-arrow-right-to-bracket"></i>](#/gitlab_default)
3030

31+
Circular dependencies are detected
32+
3133
---
3234

3335
## Hands-On [<i class="fa fa-comment-code"></i>](https://github.com/nicholasdille/container-slides/tree/160_gitlab_ci/060_artifact "060_artifact")
@@ -42,7 +44,7 @@ Test binary in a new job and stage
4244
See new `.gitlab-ci.yml`:
4345

4446
```bash
45-
git checkout 160_gitlab_ci/060_artifact -- '*'
47+
git checkout origin/160_gitlab_ci/060_artifact -- '*'
4648
```
4749

4850
---

160_gitlab_ci/070_schedules/slides.md

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ Scheduled pipelines run on a specific branch...
1818

1919
Creator is referenced and shown as the triggerer
2020

21+
Creator must have role Developer or have merge permissions on protected branches
22+
23+
Maximum frequency configured during instance rollout [](https://docs.gitlab.com/ee/administration/cicd.html#change-maximum-scheduled-pipeline-frequency)
24+
2125
### Hands-On
2226

2327
1. Schedule pipeline to run in 5 minutes

160_gitlab_ci/100_environments/slides.md

+26-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ WebDAV endpoints emulate deployment targets
3535
See new `.gitlab-ci.yml`:
3636

3737
```bash
38-
git checkout 160_gitlab_ci/100_environments/demo1 -- '*'
38+
git checkout origin/160_gitlab_ci/100_environments/demo1 -- '*'
3939
```
4040

4141
---
@@ -60,15 +60,38 @@ Branches can be used to represent target environments:
6060
See new `.gitlab-ci.yml`:
6161

6262
```bash
63-
git checkout 160_gitlab_ci/100_environments/demo2 -- '*'
63+
git checkout origin/160_gitlab_ci/100_environments/demo2 -- '*'
6464
```
6565

6666
---
6767

68-
## Pro tip: Disposable environments a.k.a. review apps
68+
## Pro tip: Disposable environments
6969

7070
Additonal use of environments: disposable review apps
7171

7272
Environments can have a [stop action](https://docs.gitlab.com/ee/ci/environments/index.html#stopping-an-environment) for disposal
7373

7474
Environments can have an [expiration time](https://docs.gitlab.com/ee/ci/yaml/#environmentauto_stop_in)
75+
76+
```yaml
77+
vscode:
78+
when: manual
79+
environment:
80+
name: quick-help
81+
url: https://quick-help.vscode.inmylab.de
82+
on_stop: vscode-cleanup
83+
auto_stop_in: 1h
84+
script: echo DEPLOY
85+
86+
vscode-cleanup:
87+
needs:
88+
- vscode
89+
environment:
90+
name: quick-help
91+
url: https://quick-help.vscode.inmylab.de
92+
action: stop
93+
when: manual
94+
script: echo DESTROY
95+
```
96+
97+
<!-- .element: style="font-size: x-large;" -->

160_gitlab_ci/110_triggers/slides.md

+101-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Ability to split automation across multiple pipeline
1212

1313
### Trigger tokens
1414

15-
Trigger pipelines using trigger tokens [](https://docs.gitlab.com/ee/ci/triggers/)
15+
Trigger pipelines through the API [](https://docs.gitlab.com/ee/ci/triggers/)
1616

1717
Fire and forget
1818

@@ -45,7 +45,7 @@ Load stages and jobs from a file using `include` [](https://docs.gitlab.com/ee/c
4545
See new `.gitlab-ci.yml`:
4646

4747
```bash
48-
git checkout 160_gitlab_ci/110_triggers/curl -- '*'
48+
git checkout origin/160_gitlab_ci/110_triggers/curl -- '*'
4949
```
5050

5151
---
@@ -104,7 +104,7 @@ Included file can also be generated before job start [](https://docs.gitlab.com/
104104

105105
---
106106

107-
## Pro tip: Variable inheritence
107+
## Pro tip 1: Variable inheritence
108108

109109
Downstream pipelines inherit some variables [](https://docs.gitlab.com/ee/ci/pipelines/downstream_pipelines.html#pass-cicd-variables-to-a-downstream-pipeline)
110110

@@ -127,3 +127,101 @@ job_name:
127127
```
128128

129129
Do not redefined masked variables - **they will not be masked**
130+
131+
---
132+
133+
## Pro tip 2: Wait for downstream pipeline
134+
135+
Upstream pipeline only waits for successful trigger
136+
137+
Wait for successul downstream pipeline using `strategy` [](https://docs.gitlab.com/ee/ci/yaml/#triggerstrategy)
138+
139+
```yaml
140+
job_name:
141+
trigger:
142+
include: child.ymal
143+
strategy: depend
144+
```
145+
146+
---
147+
148+
## Dynamic includes
149+
150+
Include can be generated on-demand:
151+
152+
```yaml
153+
generate:
154+
script:
155+
- |
156+
cat <<EOF >child.yaml
157+
test:
158+
script:
159+
- printenv
160+
EOF
161+
artifacts:
162+
paths:
163+
- child.yaml
164+
165+
use:
166+
trigger:
167+
include:
168+
- artifact: child.yaml
169+
job: generate
170+
```
171+
172+
---
173+
174+
## Pro tip: Artifacts from parent pipeline
175+
176+
Generate artifact and trigger child pipeline:
177+
178+
```yaml
179+
build_artifacts:
180+
stage: build
181+
script: echo "This is a test artifact!" >> artifact.txt
182+
artifacts:
183+
paths:
184+
- artifact.txt
185+
186+
deploy:
187+
stage: deploy
188+
trigger:
189+
include:
190+
- local: path/to/child-pipeline.yml
191+
variables:
192+
PARENT_PIPELINE_ID: $CI_PIPELINE_ID
193+
```
194+
195+
<!-- .element: style="font-size: medium;" -->
196+
197+
Fetch artifact from parent pipeline
198+
199+
```yaml
200+
test:
201+
stage: test
202+
script: cat artifact.txt
203+
needs:
204+
- pipeline: $PARENT_PIPELINE_ID
205+
job: build_artifacts
206+
```
207+
<!-- .element: style="font-size: medium;" -->
208+
209+
---
210+
211+
## Pro tip: Do not pass global variables
212+
213+
Only allow job variables to be passed to downstream pipelines:
214+
215+
```yaml
216+
variables:
217+
GLOBAL_VAR: value
218+
219+
trigger-job:
220+
inherit:
221+
variables: false
222+
variables:
223+
JOB_VAR: value
224+
trigger:
225+
include:
226+
- local: path/to/child-pipeline.yml
227+
```

0 commit comments

Comments
 (0)