Introduction to DevOps and Software Development Lifecycle (SDLC)
Chapter 7
Continuous Integration and Build Management
Diploma in DevOps
Introduction to DevOps and Software Development Lifecycle (SDLC)
•
Diploma
Continuous Integration and Build Management
Introduction and Context
Continuous integration (CI) is a software engineering practice in which developers integrate small code changes into a shared repository frequently, while an automated system verifies each change. Build management is the disciplined process of converting source code and its declared dependencies into tested, versioned, deployable outputs called artifacts.
CI and build management address a central problem in software development: code may work on one developer’s computer but fail when combined with other changes or executed in another environment. Frequent integration, automated verification, controlled dependencies, reproducible builds, and reliable artifact storage reduce this risk.
CI is not merely a tool such as Jenkins, GitHub Actions, GitLab CI/CD, Azure Pipelines, or TeamCity. It is a combination of practices, automation, version control, team behaviour, and quality controls. A technically sophisticated pipeline cannot compensate for infrequent commits, unclear ownership, unmaintainable tests, or poorly defined build inputs.
Learning Objectives
By the end of this chapter, the learner should be able to:
Explain the purpose and principles of continuous integration.
Distinguish source code, dependencies, build outputs, and artifacts.
Describe the stages of a basic CI pipeline.
Create a pipeline covering checkout, dependency management, compilation, static analysis, testing, packaging, and artifact publication.
Explain build reproducibility and identify threats to it.
Apply versioning, retention, access control, and traceability practices to an artifact repository.
Evaluate practical, security, governance, and operational limitations of CI.
1. The Foundations of Continuous Integration
1.1 Integration as a risk-management activity
Integration is the act of combining changes from different developers, branches, or teams. In a traditional approach, developers may work separately for several weeks and integrate near the end of a project. This creates a large integration event containing many simultaneous changes. Failures are then difficult to locate because the system has many possible causes.
Continuous integration reduces the size of each integration event. A developer commits a small, coherent change; the CI server obtains the change and runs automated checks. If the checks fail, the team investigates promptly while the change is still recent and its context is known.
CI therefore provides rapid feedback rather than a guarantee that software is defect-free. A green pipeline means that the defined checks passed for a particular revision and environment. It does not prove that every requirement, security property, performance condition, or production scenario is correct.
1.2 Core principles
Important CI principles include:
A shared version-control repository: Source, configuration, build definitions, and relevant scripts are versioned.
Frequent integration: Changes are integrated in small increments.
Automated builds: The system can construct the software without manual, undocumented steps.
Automated verification: Unit tests, static analysis, security checks, and other appropriate tests run automatically.
Fast feedback: Developers receive results quickly enough to act on them.
A broken-build policy: The team treats a failed main-branch build as a priority.
Traceability: A build can be related to a source revision, dependency set, pipeline run, and published artifact.
Repeatability: Equivalent inputs should produce equivalent, or acceptably equivalent, outputs.
1.3 CI compared with continuous delivery and deployment
CI focuses primarily on integrating and validating code. Continuous delivery extends the process so that a verified release candidate is always ready for deployment, usually with a controlled approval or release action. Continuous deployment automatically releases qualifying changes to a target environment.
These practices form a progression, but they are not identical. A team can practise CI without automatically deploying to production. Conversely, automatic deployment without reliable integration and testing increases operational risk.
2. The CI Pipeline Model
A pipeline is an ordered or conditionally ordered set of automated activities. A basic pipeline commonly performs the following sequence:
Continuous integration pipeline from commit to artifact repository
Figure: Continuous integration pipeline from commit to artifact repository
Figure: A basic continuous integration pipeline with feedback to the development process.
A pipeline may stop at the first failure, or it may execute independent checks in parallel and report all failures. The design should make failures visible, actionable, and attributable to a specific revision.
3. Main Pipeline Stages
3.1 Triggering and code checkout
A pipeline can be triggered by a push, pull request, scheduled event, manual action, or repository event. For a trustworthy result, the pipeline must identify the exact commit being built. Checking out a moving branch without recording its revision weakens traceability.
A checkout stage normally:
Obtains the repository contents.
Selects the commit associated with the event.
Retrieves submodules or other versioned components if required.
Records the commit identifier and relevant branch or tag.
Creates a clean workspace where possible.
Build agents should not depend on files left by earlier jobs. Ephemeral or cleaned workspaces reduce contamination from stale outputs.
3.2 Dependency management
Modern applications depend on libraries, plugins, compilers, operating-system packages, and sometimes container images. A dependency manifest declares required components, while a lockfile records resolved versions and often integrity hashes.
A sound dependency process:
declares direct dependencies explicitly;
separates production and development dependencies;
uses a lockfile when supported;
obtains packages from trusted registries or an approved proxy;
verifies checksums or signatures where available;
caches packages to improve speed without bypassing validation;
scans dependencies for known vulnerabilities and licensing constraints.
The distinction between a cache and a repository is important. A cache is an optimization and may be deleted or rebuilt. An artifact repository is a controlled source for versioned packages and build outputs.
3.3 Compilation and packaging
Compilation transforms source code into executable or intermediate representations. Some languages compile directly to machine code; others produce bytecode, bundles, or packaged source distributions. Compilation should use explicitly selected tool versions and configuration flags.
Packaging combines compiled outputs and required metadata into an artifact. Examples include a Java JAR, a Python wheel, a JavaScript package, a container image, or a compressed application bundle. Packaging should not silently include developer-specific files, credentials, temporary files, or untracked content.
3.4 Static analysis
Static analysis examines source or compiled code without executing the application. Linters identify style and simple correctness issues. Type checkers detect incompatible types. Security-oriented analyzers search for patterns associated with vulnerabilities. Quality gates can fail a build when defined thresholds are exceeded.
Static analysis is valuable because it detects some problems early and consistently. It is not a substitute for tests: a program can satisfy a linter while producing incorrect business results, and a strict analyzer can also generate false positives. Teams should define which findings are blocking, which are warnings, and how exceptions are documented and reviewed.
3.5 Automated tests
A practical CI pipeline uses several test levels:
Unit tests examine small units, usually with controlled collaborators.
Component or integration tests examine interactions with databases, services, files, or messaging systems.
Contract tests check agreed interfaces between independently developed services.
End-to-end tests exercise a complete user or business workflow.
Unit tests are generally fast and numerous. End-to-end tests often provide broader confidence but may be slower and more sensitive to environment conditions. A useful pipeline places fast feedback early while retaining tests that address meaningful risks.
Tests should be deterministic, isolated where possible, and clear about required external services. A test that sometimes passes and sometimes fails without a code change is flaky. Flaky tests reduce trust in the pipeline and should be investigated rather than routinely retried and ignored.
3.6 Artifact publication
Only outputs that pass the required quality gates should normally be published as release candidates. An artifact should have a unique identity, such as a semantic version, build number, or immutable digest. Reusing the same version for different binary contents creates ambiguity and undermines traceability.
Publication metadata should identify at least the source revision, build time, builder or pipeline, dependency information where feasible, and test or scan results. A software bill of materials (SBOM) can describe included components and support vulnerability response.
4. Build Reproducibility
A reproducible build is one for which the same declared source and build inputs produce the same output, or a formally defined equivalent output. Exact byte-for-byte reproducibility is desirable for many applications but can be complicated by timestamps, file ordering, compression metadata, compiler details, and platform differences.
Here, F is the build process; Source is the exact source revision; Dependencies are resolved component versions; Tools include compilers and package managers; Configuration includes build flags; and Environment includes operating-system and architecture assumptions. Reproducibility requires these inputs to be controlled or recorded. The expression is a model of dependency, not a numerical equation.
Common threats include:
unpinned dependency versions;
floating container tags such as latest;
different compiler or runtime versions;
network downloads that change over time;
timestamps embedded in archives;
locale, timezone, or file-order differences;
environment variables that are not documented;
generated code created by unversioned tools;
build scripts that use the developer’s home directory or machine state.
Improvement techniques include lockfiles, pinned toolchains, versioned build images, clean workspaces, offline or controlled dependency resolution, deterministic archive settings, and build metadata. Reproducibility is a spectrum: a team may first ensure that the same revision produces functionally equivalent artifacts, then improve toward byte-for-byte identity.
Reproducibility should not be confused with reliability. A process can reliably repeat a flawed build. Reproducibility answers whether controlled inputs yield the same result; correctness requires suitable verification of that result.
5. Artifact Repositories and Versioning
An artifact repository stores and distributes versioned build outputs and, in some cases, dependencies. Examples include repositories for Maven packages, npm packages, Python packages, container images, and generic binaries.
5.1 Repository functions
An artifact repository provides:
central storage and distribution;
access control and authentication;
immutable or controlled versioning;
metadata and search;
retention and cleanup policies;
replication or availability features;
audit records;
vulnerability and provenance integration.
Source control and artifact repositories serve different purposes. Source control stores human-maintained inputs and history. An artifact repository stores generated outputs that can be consumed by deployment or other builds.
5.2 Versioning practices
Semantic versioning is often expressed as major, minor, and patch components. Under its common interpretation, a backward-incompatible public API change increments the major version, a backward-compatible feature increments the minor version, and a backward-compatible defect correction increments the patch version. Teams must define how pre-release identifiers and build metadata are handled.
Semantic versioning does not determine whether a change is truly compatible; developers and reviewers must assess the public contract. For container images, immutable digests are stronger deployment references than mutable tags. Tags remain useful for human navigation, but production automation should avoid depending only on a tag that can be changed.
5.3 Promotion rather than rebuilding
A strong release process builds an artifact once, verifies it, and promotes that same artifact through environments. Rebuilding separately for testing, staging, and production can produce different binaries because dependencies or tools may have changed. Promotion preserves the tested object and improves confidence that production receives what was verified.
6. Designing a Basic CI Pipeline
The following technology-neutral design can be implemented in most CI systems:
Trigger: Start on a pull request and on changes merged to the main branch.
Checkout: Fetch the exact revision into a clean workspace.
Toolchain setup: Select pinned language, compiler, and package-manager versions.
Dependency resolution: Use the lockfile and trusted registry; validate integrity.
Compile or build: Produce the application output.
Static checks: Run formatting checks, linting, type checks, and approved security analysis.
Unit tests: Run quickly and collect reports and coverage information.
Integration tests: Start controlled services or use an approved test environment.
Package: Create a uniquely identified artifact and metadata.
Publish: Upload only after required gates pass.
Report: Display logs, test results, analysis findings, and artifact identifiers.
A simplified declarative example is shown below. Its syntax is illustrative rather than tied to one vendor:
In real use, secrets should be injected by the CI platform or a secrets manager and should not be stored in the repository or printed in logs. Permissions should follow least privilege: a pull-request job may need read-only dependency access, while publication should be restricted to trusted branches and protected workflows.
Pipeline performance
Pipeline duration affects developer feedback. Teams can improve performance by caching immutable dependencies, parallelizing independent checks, using incremental compilation where safe, and selecting a sensible test sequence. Caches must be keyed by relevant inputs such as operating system, toolchain, lockfile, and build configuration. An incorrectly keyed cache can return incompatible or stale content.
Speed must not be achieved by removing valuable checks or making failures invisible. A fast but untrustworthy pipeline is operationally expensive.
7. Worked Applied Example: A Retail Order Service
This illustrative case concerns a small team developing an order service for an online retailer.
Background and problem
Four developers previously built features on separate branches and integrated them every two weeks. Releases frequently failed because one branch used a different dependency version, database migration scripts were missing, and a developer’s local compiler differed from the production toolchain. The team also copied binary files manually to a shared server.
Analysis
The main risks were delayed integration feedback, uncontrolled dependencies, non-reproducible environments, and no reliable artifact identity. The team mapped the process from commit to deployment and found that no record connected a server binary with its source revision.
Approach and solution
The team adopted the following measures:
pull requests triggered a clean CI job;
a lockfile and toolchain configuration were committed;
a versioned build image supplied the compiler and runtime;
unit tests ran on every pull request;
database integration tests used a temporary test database;
static analysis blocked new high-severity findings;
the package included the commit identifier and build metadata;
successful main-branch builds published an immutable artifact;
staging and production promoted the same artifact;
a repository retention policy removed obsolete snapshots but retained released versions;
publication credentials were available only to protected main-branch jobs.
Outcome
Integration errors were discovered within minutes rather than at the end of a two-week cycle. Operations could identify the source revision of a deployed package, and releases no longer depended on manually copying files. The team still needed to improve end-to-end test coverage and address occasional slow integration tests.
Learning points
The most significant improvement did not come from selecting a particular CI product. It came from making inputs explicit, integrating frequently, automating verification, and treating artifacts as controlled release objects. The case also shows that CI exposes process weaknesses; it does not automatically solve them.
8. Governance, Security, and Ethical Considerations
CI systems often have access to source code, package registries, signing keys, cloud accounts, and deployment systems. They are therefore high-value targets.
Essential controls include:
protected branches and mandatory review;
least-privilege service accounts;
short-lived credentials where practical;
secret storage outside source code;
masking of sensitive log values;
dependency and container vulnerability scanning;
signed commits or artifacts where organisationally appropriate;
audit logs and review of privileged pipeline changes;
isolation of untrusted pull-request code;
controlled handling of third-party licenses;
documented exceptions and risk acceptance.
A pipeline may process personal data in test fixtures or logs. Teams should use synthetic or minimised data and comply with applicable privacy obligations. Automated quality gates can also create unfair outcomes if they measure proxies rather than meaningful quality—for example, treating code coverage as proof of correctness. Metrics should support engineering judgment, not replace it.
AI-assisted coding introduces additional concerns. Generated code may contain insecure patterns, incompatible licenses, fabricated dependencies, or errors that appear plausible. AI-generated changes should pass the same review, testing, security, and licensing controls as human-written code. Pipeline automation should not grant an AI tool unrestricted production credentials.
9. Challenges and Limitations
False confidence
A green build reflects only the checks that were implemented. Missing tests, weak assertions, untested infrastructure, and unrealistic test data can leave serious defects undetected.
Flaky tests
Flaky tests waste time and encourage teams to ignore failures. They should be measured, isolated, diagnosed, and either repaired or removed with an explicit decision.
Pipeline complexity
A pipeline that contains many tools and conditional paths may become difficult to maintain. Reusable templates, documented conventions, and versioned pipeline definitions reduce duplication.
Dependency and registry outages
External registries can be unavailable or can remove versions. Approved mirrors, controlled caches, and documented recovery procedures improve resilience, while avoiding unverified packages remains essential.
Resource cost
Build agents, storage, test environments, and artifact retention incur cost. Retention policies should distinguish temporary outputs from regulated or released artifacts.
Slow feedback
Long queues and large end-to-end suites reduce the value of CI. Teams should separate rapid verification from slower scheduled or pre-release testing without weakening release criteria.
10. Best Practices Checklist
A diploma-level practitioner should be able to apply the following checklist:
Build from a clean workspace.
Record the exact source revision.
Pin or lock important dependencies.
Version the toolchain and pipeline definition.
Run static analysis and meaningful automated tests.
Make failures visible and actionable.
Do not ignore or permanently retry flaky tests.
Produce uniquely identifiable artifacts.
Store artifacts in a controlled repository.
Promote the tested artifact instead of rebuilding it.
Protect secrets and restrict publication permissions.
Retain audit evidence and relevant metadata.
Review pipeline performance and quality periodically.
Chapter Summary
Continuous integration integrates small changes frequently and verifies them automatically. Build management controls the transformation from source and dependencies into traceable, tested artifacts. A basic CI pipeline checks out an exact revision, resolves dependencies, compiles or packages software, performs static analysis, runs automated tests, and publishes approved artifacts.
Reproducibility depends on controlling or recording source, dependencies, tools, configuration, and environment. Lockfiles, pinned toolchains, clean workspaces, controlled registries, and deterministic packaging reduce variation. Artifact repositories provide versioning, access control, metadata, retention, and distribution; they should be used to promote the same tested artifact through environments.
CI improves feedback and reduces integration risk, but it does not prove complete correctness. Test quality, security, governance, privacy, licensing, pipeline performance, and human review remain necessary. The professional objective is not simply a green pipeline, but a trustworthy, repeatable, secure, and traceable software delivery process.
Key Terms
Continuous integration: Frequent integration of code changes with automated verification.
Build management: Control of the processes and inputs that create software outputs.
Pipeline: An automated sequence of software delivery activities.
Checkout: Retrieval of a specified source revision into a workspace.
Dependency: An external library, tool, service, or component required by a build or application.
Manifest: A file declaring project dependencies and configuration.
Lockfile: A file recording resolved dependency versions and often integrity information.
Compilation: Transformation of source code into executable or intermediate output.
Static analysis: Examination of code without executing the application.
Unit test: A test of a small software unit in isolation or near isolation.
Integration test: A test of interactions between components or external systems.
Flaky test: A test whose result changes without a relevant change in code or inputs.
Artifact: A versioned output produced by a build.
Artifact repository: A controlled store for packages, binaries, images, and metadata.
Reproducible build: A build whose controlled inputs produce the same or defined equivalent output.
Toolchain: The compilers, runtimes, package managers, and related tools used to build software.
Provenance: Information describing where an artifact came from and how it was produced.
SBOM: Software bill of materials listing components included in a software product.
Quality gate: A rule that determines whether a pipeline may proceed.
Promotion: Moving the same verified artifact between environments.
Review Questions
5 Short Answer Questions
What problem does continuous integration address?
Why should a pipeline check out an exact source revision?
State two differences between a dependency cache and an artifact repository.
What is the purpose of a lockfile?
Why is a flaky test harmful to a CI process?
5 Long Answer Questions
Explain the stages of a basic CI pipeline from commit through artifact publication.
Discuss the relationship between continuous integration, continuous delivery, and continuous deployment.
Explain the main causes of non-reproducible builds and methods for controlling them.
Describe how an artifact repository supports traceability, security, and release management.
Evaluate the claim that a green pipeline proves that software is correct.
3 Analytical / Application Questions
A team’s build passes locally but fails in CI because developers use different compiler and dependency versions. Diagnose the problem and propose a reproducible-build design.
Design a CI pipeline for a small web application that uses a database. Identify the stages, test levels, security controls, and artifact strategy.
A production deployment used an image tag that was later overwritten. Analyse the risks and recommend a versioning and promotion policy.
Multiple Choice Questions with Answers
Question 1
What is the primary purpose of continuous integration?
A. To eliminate the need for software testing
B. To integrate changes frequently and verify them automatically
C. To deploy every commit directly to production
D. To replace version control with an artifact repository
Correct Answer: B. To integrate changes frequently and verify them automatically
Question 2
Which item most directly improves dependency reproducibility?
A. Using the newest available package on every build
B. Installing packages manually on each developer computer
C. Committing and using a dependency lockfile
D. Disabling dependency integrity checks
Correct Answer: C. Committing and using a dependency lockfile
Question 3
What should a trustworthy checkout stage identify?
A. Only the developer’s username
B. The exact source revision being built
C. The most recently modified local file
D. An arbitrary branch tip without recording its revision
Correct Answer: B. The exact source revision being built
Question 4
Which activity is an example of static analysis?
A. Executing a customer purchase workflow
B. Deploying an application to production
C. Inspecting source code for insecure patterns without running it
D. Copying an artifact to a repository
Correct Answer: C. Inspecting source code for insecure patterns without running it
Question 5
Why should a release process preferably promote an artifact rather than rebuild it for each environment?
A. Promotion guarantees that all tests are unnecessary
B. Rebuilding always produces smaller files
C. The same verified object is used across environments
D. Promotion removes the need for version numbers
Correct Answer: C. The same verified object is used across environments
Question 6
Which practice best protects secrets in a CI pipeline?
A. Committing credentials in the pipeline file
B. Printing credentials in logs for troubleshooting
C. Storing credentials in a managed secret store and limiting access
D. Using one shared administrator password for every job
Correct Answer: C. Storing credentials in a managed secret store and limiting access
Question 7
Which statement about a green pipeline is most accurate?
A. It proves that the software has no defects
B. It proves that every possible production scenario was tested
C. It shows that the defined checks passed for the tested revision and environment
D. It means static analysis was not required
Correct Answer: C. It shows that the defined checks passed for the tested revision and environment
Question 8
Which is a likely threat to build reproducibility?
A. A pinned compiler version
B. A clean build workspace
C. A floating dependency version that changes over time
D. A committed lockfile
Correct Answer: C. A floating dependency version that changes over time
Question 9
What is the main role of an artifact repository?
A. To provide a controlled store for versioned build outputs and packages
B. To replace all automated tests
C. To edit source code collaboratively instead of using version control
D. To generate requirements without developer input
Correct Answer: A. To provide a controlled store for versioned build outputs and packages
Question 10
Which test type usually examines a small unit of code with controlled collaborators?
A. Unit test
B. End-to-end test
C. Load test
D. Disaster-recovery test
Correct Answer: A. Unit test
Introduction to DevOps and Software Development Lifecycle (SDLC)
Chapter 7
of 14