Trace a software change from issue to deployment
GitLab combines Git repositories, issues, merge requests and automated CI/CD pipelines in one development environment. Its practical value is traceability: an issue specifies a change, a branch contains the implementation, a merge request records review and a pipeline reports tests. A project should define who can merge into protected branches, who can modify pipeline configuration and who can authorize production deployment.
Traceability depends on stable references between work items and code. Link a change request to a branch and merge request, include the reason for the change in the description and ask reviewers to examine both behavior and deployment implications. When an issue covers a security-sensitive configuration change, the reviewer should confirm which protected variable or environment will be affected. A green pipeline does not replace the judgment needed to accept changed permissions, migrations or infrastructure rules. Review policies should be proportionate to the repository’s risk and team responsibilities.
For a beginner exercise, create a repository with a small program and one test. Open a merge request from a feature branch, inspect the diff, explain a failure and require a passing pipeline before merging. Keep the example intentionally small so the workflow is visible instead of buried in infrastructure setup.
Start with a deliberately failing unit test. Commit a small behavior change without updating its test, open a merge request and identify the failed job, test assertion and line of code. Correct the behavior on the same branch and rerun the pipeline. Inspect both runs rather than only the final green status. This teaches a useful debugging sequence: reproduce a failure, isolate its cause, change one thing and demonstrate recovery. Protect the main branch so experiments remain in review until they satisfy the agreed merge conditions.
Merge conflicts provide a second practice scenario. Have two feature branches edit the same configuration key, then merge one and rebase or merge the other against the updated target. The correct resolution is not automatically to accept the newest line: compare intended application behavior, environment assumptions and test outcomes. Review the final diff for accidentally removed settings. Repeat the CI test on the resolved commit; a passing pipeline on an earlier commit does not prove the merged result is safe.
Understand jobs, runners and stages
According to GitLab’s pipeline documentation, a .gitlab-ci.yml file defines jobs that run on runners, with stages controlling ordering. Jobs in the same stage can run concurrently; different stages ordinarily run in sequence. This is a minimal example to run a test in an available Python runner:
A pipeline’s job graph matters when builds are expensive or test suites are independent. Stages offer a basic sequence, while dependency declarations can allow eligible jobs to begin without waiting for all work in an earlier stage. Model a build, unit test, integration test and deployment job. Explain which jobs require artifacts and which can safely run in parallel. If a deployment job requires a package that has not been produced, the graph is wrong even if its YAML passes syntax validation.
Runner selection also affects reliability. Jobs may execute in a container, a shell on a managed runner or another executor, each with different isolation and maintenance duties. A shared runner should not be assumed to provide the same trust boundary as a dedicated build worker with restricted network access. Capture the runner tags, execution image and permissions in a training environment. If a job remains pending, first verify eligibility, runner availability and project configuration before editing the program being built.
stages:
- test
unit_tests:
image: python:3.12
stage: test
script:
- python -m unittest discover -v
This configuration presumes a repository with suitable Python tests and an authorized runner that can fetch the specified image. If the pipeline cannot run, inspect runner availability and job logs before modifying unrelated settings. A successful pipeline proves only the tests it actually executed.
When a test job hangs, inspect the last successful log line and determine whether the application is waiting on a database, network resource or unavailable runner capacity. Set justified timeouts for operations that might block indefinitely, and distinguish a timed-out job from a failed assertion. Where possible, make external dependencies deterministic by using controlled fixtures or mock services. Record what the pipeline did not actually test so its green result is not misrepresented as a full end-to-end guarantee.
Artifacts, package delivery and secrets
GitLab describes job artifacts as files generated by jobs, such as test reports or build outputs. They are not the same as a controlled package release. Set appropriate retention and permissions, and avoid placing tokens, customer data or secrets in publicly downloadable artifacts. Use a package registry for durable distribution when the workflow requires it.
Artifacts, caches and package registries solve different problems. A cache speeds up repeated dependency downloads and may be safely rebuilt; a job artifact passes a test report or build output between jobs; a package registry supports managed distribution with versions and access controls. For a sample Python service, store a test-report artifact briefly, cache appropriately scoped dependencies and publish a release package only after review. Keep retention periods and access rules explicit, since retaining build outputs indefinitely can expose code or consume storage unnecessarily.
Treat CI variables and deployment credentials as privileged configuration. Restrict which branches or environments may use sensitive values, rotate compromised tokens and review third-party pipeline includes. A pipeline file is executable automation, so changes to its content deserve security review just like application code.
For a secret-handling exercise, compare a harmless project variable with a credential marked for restricted use. Check whether branch protection and environment-scoping rules prevent unreviewed code from accessing sensitive values. Masking can reduce accidental display but should not be treated as a substitute for restricting who can run privileged jobs. Never print real tokens as a test. Use dummy credentials and inspect whether pipeline logs, artifacts or exception messages could reveal them. Document rotation and revocation steps for a suspected exposure.
Third-party pipeline templates are code dependencies. Before importing a shared CI configuration, inspect the exact revision or version, the scripts it can execute, any network destinations it contacts and the permission scope of secrets exposed to it. For an update drill, pin the previous known-good reference, test a changed version in a nonproduction branch and compare the resulting job graph. A successful lint check does not prove the imported script is safe, just as a dependency scanner cannot prove application logic is correct.
Release controls and failure recovery
For production delivery, define a review and approval boundary, an immutable artifact version and a rollback method. Deploying from an unreviewed feature branch creates a different risk than testing that branch in isolation. Prefer repeatable deployments that record the artifact, environment and owner of the change.
An environment record should identify the deployed revision, deployment job, responsible actor and recovery procedure. Use separate development and production targets so an unreviewed experiment cannot overwrite the live service. Where the GitLab edition supports protected environments, use its allowed-to-deploy controls; otherwise enforce equivalent authorization in the available platform and delivery process. A deployment should validate readiness and a representative application transaction after rollout. A job completing successfully while users receive errors is an incomplete release verification.
When a deployment fails, begin with evidence: which job failed, what configuration changed, what artifacts were produced and which environment was affected? A useful post-incident review records the root cause and the prevention test added to the pipeline. Do not assume that using CI/CD automatically provides secure DevOps.
Practice rollback using an immutable tagged image or package and a known prior configuration. Deploy a harmless feature change in a test environment, simulate a failed health check and restore the previous release without editing application files manually on the server. Confirm the running version, route availability and logs after the rollback. Document which data changes cannot be reversed simply by swapping an image; database migrations often need a separate compatibility and recovery strategy. These constraints belong in the release plan.
What to learn next
The technical progression is Git basics, review workflows, YAML pipeline jobs, runners, artifacts and guarded deployment. Study container delivery and cloud access only after that foundation is reliable. A natural next topic is CI/CD toolchain skills across other DevOps tools.
Measure whether pipeline improvements actually help. Compare median time from merge request opening to first test feedback, flaky-test rates, queue delays and the proportion of deployments needing manual intervention. A pipeline with more stages or scanners is not necessarily better if it produces ambiguous failures and long queues. Separate performance problems in the runner fleet from inefficient dependency handling or poorly partitioned tests. Prioritize changes that improve trustworthy feedback while maintaining security and reproducibility.
For services deployed on Kubernetes, the separate application deployment and troubleshooting workflow explains readiness probes, controllers and runtime verification. That relationship helps connect a delivery pipeline to actual application behavior without implying that GitLab usage is part of a CKAD issuer exam requirement.
For a Kubernetes deployment, connect the pipeline record to the actual cluster workload. Record the desired image digest, namespace and rollout strategy. After deployment, check that the deployment controller reports the intended revision, pods are ready and a representative request reaches the service. A healthy build job does not prove that a container can load secrets or contact its dependencies at runtime. If the rollout stalls, inspect pod events and readiness failures before rerunning unrelated pipeline stages.