Scrivio Interview library
DesignAdvanced6 min read · updated 12 November 2026

Design shared CI templates for 100 Java repositories so that teams get consistent builds but can still customise.

Publish versioned, reusable pipeline templates, such as GitHub reusable workflows, GitLab CI components or a Jenkins shared library, with standard stages for build, test, scan and publish. Teams call them with a few parameters, such as JDK version and which test stages to run, instead of copying and editing pipeline files. Security steps like scanning, signing and SBOM generation stay mandatory and outside team control. New template versions roll out gradually with tracking of which repository uses which, and pipeline duration and failure causes are measured centrally.

Why this question is asked

With 100 Java repositories, there are two ways things go wrong. Either every team writes its own pipeline and we end up with 100 slightly different builds, half of them missing security scanning, or a central team forces one rigid pipeline that does not fit anyone and gets bypassed. Interviewers ask this to see whether we can find the middle: consistency where it matters, flexibility where it is safe. In this answer, we will look at the structure of the templates, the parameters teams get, the steps they cannot change, how to version and roll out changes, and how to measure the result.

1Why Copy-and-Edit Pipelines Fail

Most organisations start with a good pipeline in one repository, which other teams copy. Within a year, each copy has been edited: one team upgraded the JDK, another disabled a flaky scan, a third added caching. When a new requirement arrives, for example signing every image, someone has to open 100 pull requests, each to a slightly different file. Security and platform teams cannot tell which repositories actually run the required checks.

Reusable templates replace the copies with a reference. The repository's pipeline file becomes a few lines that call a shared definition at a specific version, so the logic lives in one place and changes once.

2The Shape of the Templates

The templates live in a dedicated repository owned by the platform team. They define the standard stages for a Java service: set up the pinned JDK and dependency cache, build and test with Maven or Gradle, run static analysis and the quality gate, build the container image, generate the SBOM, scan, sign and publish. Each mechanism has its own form, GitHub Actions reusable workflows and composite actions, GitLab CI includes and components, Jenkins shared libraries, but the idea is the same.

YAML
# in each service repository: .github/workflows/ci.yml, the whole file
name: ci
on: [pull_request, push]
jobs:
java:
uses: acme/ci-templates/.github/workflows/java-service.yml@v3 # pinned major version
with:
java-version: '25' # allowed values: 21, 25
build-tool: maven
integration-tests: true # run the Failsafe stage
extra-maven-args: '-Pcontract-tests'
secrets: inherit
Step throughWhat a service pipeline is made of
  1. Service pipeline filea few lines: template version and parameters
  2. Team extension pointsextra build args, optional stages, extra jobs after the template
  3. Shared template stagessetup, build, test, analysis, image, publish
  4. Mandatory platform stepsscan, SBOM, sign, provenance; not configurable

4 layers, from the top down. Step through them one at a time.

Teams choose from the top layers; the bottom layer is the same for everyone.

Notice how little the team writes. The template's inputs are the contract: a short list of supported parameters with documented values. If a team needs something the template does not offer, they ask for a new parameter, and if several teams need it, it becomes part of the template. This keeps the variation explicit and small.

3Parameters, Not Forks

The art is choosing parameters. Too few, and teams fork the templates; too many, and the templates become a programming language nobody understands. In practice a handful covers most services: JDK version from an approved list, Maven or Gradle, which test stages to run, extra build arguments, and whether to publish an image or a library. Teams can still add their own jobs before or after the template's jobs, for example a performance test or a custom deployment check, without touching the shared stages.

Each parameter needs validation in the template. If java-version accepts any string, someone will pass 11 and wonder why the build is slow and unsupported. A clear error, such as java-version must be one of 21, 25, saves support time.

4Mandatory Security Steps Outside Team Control

Some steps are not optional: vulnerability scanning of the image and dependencies, generating an SBOM, signing the image and recording provenance. These stay inside the template with no parameter to turn them off. If a scan finds a critical vulnerability with no fix, the exception goes through a reviewed allow-list owned by security, with an expiry date, rather than through a pipeline flag.

Templates alone cannot stop a team from deleting the template call and writing its own pipeline. So we add enforcement on the platform side: organisation rules or required workflows on the repository host that must pass before merging, and a deployment platform that only accepts images signed by the template's signing identity. Then the template is the easiest way to ship, and bypassing it simply does not produce a deployable artifact.

5Versioning and Rolling Out Changes

Templates are software and get versions. We use semantic versions with tags, v3.4.1, and a moving major tag, v3, that most repositories reference. Compatible improvements, such as a faster cache, go into v3 and reach everyone at once, after testing on a set of canary repositories, a few real services that opt into the newest version first. Breaking changes, such as dropping JDK 21, go into v4, and repositories move with automated pull requests from a dependency bot, team by team.

We also need to know where we stand. A small job, or a query over the repositories' pipeline files, records which template version each repository uses. That shows how many repositories are still on v2 and which teams to help before v2 is retired.

Step throughRolling out a new template version
  1. Change merged in ci-templatestests run on sample projects
  2. Canary repositories use it5 real services opt in early
  3. Breaking change?
    YesRelease v4, open upgrade PRsNoMove the v3 tag, everyone gets it
  4. Track versions per repositorydashboard of v2, v3, v4 usage
  5. Retire the old majorannounced date, help the stragglers

5 steps in order. Play them, or step through them one at a time.

Compatible changes reach everyone; breaking ones move repository by repository.

6Measuring Builds Centrally

Because every repository runs the same stages, we can measure them in the same way. The templates send pipeline events, duration per stage, success or failure, and a failure category, to a central place. Then we can answer useful questions: median pipeline time across 100 repositories, perhaps 9 minutes; which stage is slowest; which failures are infrastructure problems, such as registry timeouts, rather than real test failures. A template change that adds a minute to every build, or a flaky scanner that fails 3 percent of runs, shows up within a day instead of being discovered through complaints.

7Follow-up questions

What if a team has needs the template cannot meet?

First see whether a new parameter or an extension point solves it. If the service is truly different, for example a native image build with special tooling, the platform team can offer a second template. Teams writing fully custom pipelines should still call the mandatory security steps as a shared action and go through the same signing, so the deployment platform accepts their artifacts.

How do we test changes to the templates themselves?

Keep a few small sample projects, a Maven service, a Gradle library, a multi-module build, in the templates repository and run the templates against them on every change. Then use canary repositories for real-world testing before moving the major tag.

Should the moving tag or exact versions be used?

A moving major tag such as v3 gets fixes to everyone quickly, which suits a central team that tests carefully. Exact versions give each team full control but spread updates slowly. Many organisations use the major tag by default and exact versions only for repositories that need to freeze their build.

8Conclusion

In this answer, we designed shared CI templates for 100 Java repositories: versioned reusable templates with standard stages, a small set of validated parameters instead of copying and editing, mandatory scanning, signing and SBOM steps outside team control and enforced by the platform, gradual rollout through canaries and major versions with tracking of which repository uses which, and central measurement of pipeline duration and failure causes.

What to say in the interviewAbout 90 seconds aloud

Open with

I would build a small internal product: a ci-templates repository owned by the platform team, with versioned reusable workflows, or GitLab components or a Jenkins shared library depending on our tooling.

Then, if they want more

The template has the standard stages: pinned JDK and dependency cache, build and test, static analysis and quality gate, image build, SBOM, scan, sign and publish.

Each service's pipeline file becomes a few lines that call the template at a major version and pass a handful of validated parameters, such as JDK version from an approved list, Maven or Gradle, which test stages to run and extra build arguments.

Teams can add their own jobs around it but not edit the shared stages, and if many teams need something, it becomes a parameter. Security steps are mandatory with no switch to turn them off; exceptions go through a reviewed allow-list.

To stop bypassing, I would combine required checks on the repository host with a deployment platform that only accepts images signed by the template. Changes roll out through canary repositories, compatible ones by moving the major tag and breaking ones as a new major with automated upgrade pull requests, and I track which repository uses which version.

Finally the template reports stage durations and failure causes centrally, so we can see slow stages and infrastructure flakiness across all 100 builds.

About this answer

Last updated
12 November 2026
Versions it names
Java 21
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Design shared CI templates for 100 Java repositories so that teams get consistent builds...": https://scrivio-interview-library.netlify.app/java/version-control-and-ci/71bb20568d/