- The speaker has 8 years of experience in programming and devops practices using Gitlab CI.
- Gitlab CI allows automating pipelines for consistency, early problem detection, reduced friction, and increased resilience.
- Gitlab CI configuration can define stages, jobs, dependencies between jobs using DAGs, includes, templates, variables, and rules.
2. About the speaker
- Background in programming
- 8 years of experience
- Currently @ barrage.net - Osijek - Croatia
- Specialized in devops practices and security
- Successfully using Gitlab CI in production over 6 years
2
Barrage d.o.o. | Dedication - Technology - Progression - Productivity - Flexibility | Intro
3. Why did we started practicing DevOps
- Shift from occasionally performed, to routinely performed
- Enabled via automation - automation isn't the goal it’s the technique to achieve
the goal
- Drive consistency
- Detect problems early
- Remove friction
- Increase your bus factor!
Intro | Pipeline configuration | Pipeline reuse | Pipeline controls
3
Barrage d.o.o. | Dedication - Technology - Progression - Productivity - Flexibility | Intro
4. Gitlab CI configuration management
- Pipeline configuration
- DAG
- Parent/Child
- Multi-project
- Pipeline component reuse
- Before and after scripts
- Includes, templates and extends
- Pipeline controls
- Variables
- Rules
Intro | Pipeline configuration | Pipeline reuse | Pipeline controls
4
Barrage d.o.o. | Dedication - Technology - Progression - Productivity - Flexibility | Intro
5. Pipeline configuration - basic
Intro | Pipeline configuration | Pipeline reuse | Pipeline controls
5
Barrage d.o.o. | Dedication - Technology - Progression - Productivity - Flexibility | Pipeline configuration
All jobs in a Stage must
complete successfully before
proceeding to the next stage
6. Pipeline configuration - with options
Intro | Pipeline configuration | Pipeline reuse | Pipeline controls
6
Barrage d.o.o. | Dedication - Technology - Progression - Productivity - Flexibility | Pipeline configuration
This job has
`allow_failure: true`
…so the pipeline proceeds
even though job failed
This job has
`when: manual`
...so it waits for someone
with the permission to click
a “Play” button”
10. Pipeline configuration - Parent/Child pipelines for
Monorepos
Intro | Pipeline configuration | Pipeline reuse | Pipeline controls
10
Barrage d.o.o. | Dedication - Technology - Progression - Productivity - Flexibility | Pipeline configuration
Run the job if there are
changes in those files
Include files from
elsewhere in the project -
must reference a YAML file
`strategy: depend`
Means to hold this pipeline
until the other pipeline
finishes
11. Pipeline configuration - Multi-Project pipelines
Intro | Pipeline configuration | Pipeline reuse | Pipeline controls
11
Barrage d.o.o. | Dedication - Technology - Progression - Productivity - Flexibility | Pipeline configuration
The job with trigger is
referred to as the “bridge”
job
Specify project and branch
12. Pipeline reuse - “before” and “after” scripts
Intro | Pipeline configuration | Pipeline reuse | Pipeline controls
12
Barrage d.o.o. | Dedication - Technology - Progression - Productivity - Flexibility | Pipeline reuse
The “Before” script is
concatenated to the main
script and runs in the same
shell
The “After” script is run in a
separate shell and does not
not impact the success exit
code
Both works well with a
“default” block
13. Pipeline reuse - Local include
Intro | Pipeline configuration | Pipeline reuse | Pipeline controls
13
Barrage d.o.o. | Dedication - Technology - Progression - Productivity - Flexibility | Pipeline reuse
Includes are processed
when the CI is parsed (on
Gitlab itself, not on a
Runner)
`local` is the default.
It includes CI configuration
from elsewhere in this
project.
14. Pipeline reuse - Project and Remote include
Intro | Pipeline configuration | Pipeline reuse | Pipeline controls
14
Barrage d.o.o. | Dedication - Technology - Progression - Productivity - Flexibility | Pipeline reuse
Include CI configuration
from another project on the
Gitlab instance
Or from a raw URL
anywhere in the network
15. Pipeline reuse - Extending templates of Gitlab
Intro | Pipeline configuration | Pipeline reuse | Pipeline controls
15
Barrage d.o.o. | Dedication - Technology - Progression - Productivity - Flexibility | Pipeline reuse
Templates are developed
by Gitlab and come with
Gitlab instance
Different types of “templates” in Gitlab
- CI configuration templates
- Project templates
- Issue and Merge request description
templates
16. Pipeline reuse - Project and Remote include
Intro | Pipeline configuration | Pipeline reuse | Pipeline controls
16
Barrage d.o.o. | Dedication - Technology - Progression - Productivity - Flexibility | Pipeline reuse
Jobs starting with a dot (“.”)
are “hidden” - they are only
used for inheritance and
don’t run on their own.
The `extends` block means
to inherit the references
block, and override any
hashes that are listed here.
17. Pipeline controls - Variables in the UI at the Project Level
Intro | Pipeline configuration | Pipeline reuse | Pipeline controls
17
Barrage d.o.o. | Dedication - Technology - Progression - Productivity - Flexibility | Pipeline controls
Variables can also be set at
the Group and Instance
level
18. Pipeline controls - Variables for a Pipeline run
Intro | Pipeline configuration | Pipeline reuse | Pipeline controls
18
Barrage d.o.o. | Dedication - Technology - Progression - Productivity - Flexibility | Pipeline controls
Prepopulate the keys and values using
URL parameters
.../pipelines/new?ref=<branch>&var=[<v
ariable_key>]=<value>
21. Pipeline controls - How variables are processed
- Values for this run
- Manually (UI) or in API request
- Values configured
- For Project, Group or Instance
- Values inherited
- From Jobs in previous Stages
- Values in YAML
- Using the `variables:` block
- Values from Gitlab
- “Predefined Variables”
Intro | Pipeline configuration | Pipeline reuse | Pipeline controls
21
Barrage d.o.o. | Dedication - Technology - Progression - Productivity - Flexibility | Pipeline controls
CI Engine
Main Gitlab
server
CI Jobs
Gitlab Runner
22. Pipeline controls - rules: The Basics
-
Intro | Pipeline configuration | Pipeline reuse | Pipeline controls
22
Barrage d.o.o. | Dedication - Technology - Progression - Productivity - Flexibility | Pipeline controls
“If” statements can
reference Variables -
including the predefined
ones, as in this case
24. Pipeline controls - rules examples
-
Intro | Pipeline configuration | Pipeline reuse | Pipeline controls
24
Barrage d.o.o. | Dedication - Technology - Progression - Productivity - Flexibility | Pipeline controls
If $CI_PIPELINE_SOURCE is set to
merge_request_event
or schedule, the job is executed
Any other value for $CI_PIPELINE_SOURCE
does not execute the job because there is no
standalone `when:` clause
If $CI_PIPELINE_SOURCE is set to any valid
value other than
merge_request_event or schedule, the job is
executed
25. Pipeline controls - when do pipelines run?
-
Intro | Pipeline configuration | Pipeline reuse | Pipeline controls
25
Barrage d.o.o. | Dedication - Technology - Progression - Productivity - Flexibility | Pipeline control
New commit
New branch
New tag
Manual
API call
Scheduled
The variable
ci_pipeline_source
...can help us with this. Values include:
- push
- web
- schedule
- api
- chat
- webide
- trigger
- pipeline
- external
- external_pull_request_event
- parent_pipeline
- merge_request_event
26. Extra information
- Gitlab API
- Gitlab CLI CLI https://python-gitlab.readthedocs.io/
- Leveraging and extending Auto Devops feature
- Job artifacts
- Container and language-specific registries
- Parallel and Matrix Testing
- ………..
26
Barrage d.o.o. | Dedication - Technology - Progression - Productivity - Flexibility
27. Thank you!
Q&A
Feel free to reach out if you have any questions!
hello@barrage.net || www.barrage.net
27
Barrage d.o.o. | Dedication - Technology - Progression - Productivity - Flexibility