CI build and release checks
What you will learn
Continuous integration (CI) checks every proposed change; continuous delivery produces a deployable artifact. A promotion pipeline moves the same reviewed bytes between environments, rather than rebuilding for each one. Deployment is a separate authorized operation, followed by verification and a compatible rollback plan.
- Explain the build, evidence, approval and promotion stages.
- Use a content digest to compare artifacts.
- Reject promotion or rollback when required evidence is missing.
Plain Java examples: save as Main.java in a fresh directory, then run javac --release 21 Main.java and java Main. Standalone Java 21 functional examples. These are offline Java 21 models, not cloud or hosted CI execution. Companion local pipeline evidence is separate.
Require all release gates
public class Main { record Checks(boolean tests, boolean scan, boolean sbom, boolean approved) { boolean promotable() { return tests && scan && sbom && approved; } } public static void main(String[] args) { System.out.println(new Checks(true,true,true,true).promotable()); System.out.println(new Checks(true,false,true,true).promotable()); }}Expected output:
truefalseMissing scan evidence prevents the second promotion.
Pipeline stages and evidence
Use a pinned JDK and reviewed build tool; compile, test, perform dependency and secret scans, create a software bill of materials (SBOM), package and hash the output. Bind scan results and attestations to the commit and artifact digest. Store immutable bytes, then gate staging and production separately. A pass means a tool completed its declared check, not proof of security. Keep production credentials away from untrusted pull requests. Pin approved actions by full commit SHA; scope runner permissions and avoid executing unreviewed build scripts.
Promotion and schema changes
Verify the exact digest against the authorized release manifest and trusted provenance before staging. Test migrations using expand/contract: add compatible structure first, deploy compatible readers/writers, backfill, and remove obsolete fields only after rollback windows close. Check health and agreed SLOs before increasing traffic. Roll back to a known compatible digest, or stop and use a forward fix if the old code cannot read the migrated schema. The companion lab exercises only local artifact identity, not signature verification or a hosted runner.
Verify artifact identity
import java.nio.charset.StandardCharsets;public class Main { static String digest(byte[] bytes) throws java.security.NoSuchAlgorithmException { return java.util.HexFormat.of().formatHex(java.security.MessageDigest.getInstance("SHA-256").digest(bytes)); } public static void main(String[] args) { try { byte[] staged="catalog-v1".getBytes(StandardCharsets.UTF_8); byte[] production=staged.clone(); System.out.println(digest(staged).equals(digest(production))); production[0]=0; System.out.println(digest(staged).equals(digest(production))); } catch (java.security.NoSuchAlgorithmException e) { throw new IllegalStateException(e); } }}Expected output:
truefalseThe equality check detects changed bytes. The trusted expected digest must come from a separate authenticated source.
Check rollback schema compatibility
public class Main { record Release(String digest, int minSchema, int maxSchema) { Release { if (digest.isBlank() || minSchema < 0 || maxSchema < minSchema) throw new IllegalArgumentException("release"); } boolean supports(int schema) { return schema >= minSchema && schema <= maxSchema; } } public static void main(String[] args) { var old=new Release("previous",1,2); var next=new Release("candidate",2,3); System.out.println(old.supports(2) && next.supports(2)); System.out.println(old.supports(3)); }}Expected output:
truefalseSchema 2 supports both versions; schema 3 excludes the previous one.
Common mistakes
Do not rebuild a tested JAR from a moving branch for production, treat an SBOM as a vulnerability scan, or approve a release based solely on a green build. A rollback is not automatically a database rollback.
Practice
Evaluate a release with tests, scan and SBOM passed but approval missing; print the decision.
Expected output:
falseCompare with the manual review criteria.
Further reading: CI security · Attestations. Independent editorial review remains pending.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
CI build and release checks — knowledge check
Cloud deployment and CI/CD reasoning.
What should move from staging to production?
What does an SBOM list?
When should a release gate pass?
What does a hash alone prove?
When can old code be redeployed?