Building a GitLab CI/CD Pipeline
Unlock the complete study guide + 1,040 practice questions across 16 full exams.
Bundled into the existing Designing, Deploying and Managing Network Automation Systems premium course — no separate purchase.
14-day money-back guarantee — no questions asked.
Included in this chapter:
- The four-stage network-automation pipeline
- Anatomy of a job: script, image, and tags
- Build: render the artifact, never touch a device
- Prevalidation: prove it is safe, change nothing
- Deploy: the one stage that changes devices
- Post-validation: verify the outcome, not the exit code
- Artifacts, needs, and dependencies
- Rules, variables, and secrets
The four network-automation pipeline stages
| Aspect | Build | Prevalidation | Deploy | Post-validation |
|---|---|---|---|---|
| When it runs | First | Before deploy | The change itself | After deploy |
| Device I/O | None | Read-only (predict) | Writes config | Read-only (verify) |
| What it does | Render/package the artifact | Lint + dry-run it | Apply it to devices | Confirm the result |
| Typical tools | Ansible template, docker:dind/Kaniko | yamllint, --syntax-check, --check, terraform plan | ansible-playbook, terraform apply, RESTCONF/NETCONF | pyATS learn/diff/assert, ping |
| On failure | Pipeline stops, nothing changed | Deploy skipped, nothing changed | State may be partial | Change is live; triggers rollback or alert |
Decision tree
Cheat sheet
Unlock with Premium — includes all practice exams and the complete study guide.
References
- https://docs.gitlab.com/ci/yaml/
- https://docs.gitlab.com/ci/pipelines/pipeline_architectures/
- https://docs.gitlab.com/runner/executors/
- https://docs.gitlab.com/runner/executors/shell/
- https://docs.ansible.com/ansible/latest/collections/ansible/builtin/template_module.html
- https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_templating.html
- https://docs.gitlab.com/ci/docker/using_docker_build/
- https://docs.gitlab.com/ci/docker/using_kaniko/
- https://docs.ansible.com/ansible/latest/cli/ansible-playbook.html
- https://developer.hashicorp.com/terraform/cli/commands/validate
- https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_checkmode.html
- https://developer.hashicorp.com/terraform/cli/commands/plan
- https://docs.gitlab.com/ci/variables/predefined_variables/
- https://docs.gitlab.com/ci/yaml/deprecated_keywords/
- https://docs.gitlab.com/ci/jobs/job_control/
- https://docs.gitlab.com/ci/environments/protected_environments/
- https://docs.gitlab.com/ci/environments/
- https://docs.gitlab.com/ci/environments/deployments/
- https://developer.cisco.com/docs/pyats/
- https://developer.cisco.com/docs/ansible-fest-lab-guide/gitlab-cicd/
- https://docs.gitlab.com/ci/testing/unit_test_reports/
- https://docs.gitlab.com/ci/jobs/job_artifacts/
- https://docs.gitlab.com/ci/yaml/workflow/
- https://docs.gitlab.com/ci/variables/
- https://docs.gitlab.com/ci/secrets/id_token_authentication/