Dynamically generate CI/CD pipelines
designing pipeline-as-code that adapts to a repo.
a detection step scans for marker files and maps them to reusable stage templates assembled at runtime; trade off convention/DRY against reduced transparency and harder debugging.
What's really being asked
This advanced question probes platform-engineering judgment: can you build a convention-over-configuration pipeline system and honestly weigh the loss of explicitness against the gain in consistency.
The full answer
Design it in two phases. A detection phase checks out the repository and scans for marker files: a pom.xml or build.gradle implies a JVM build, a Dockerfile implies a container build, a package.json implies a Node build and test, presence of test directories implies a test stage. Map each detected marker to a reusable, parameterized stage template stored centrally, so logic lives in one place. An assembly phase composes the selected templates, in a sensible order with dependencies, into a concrete pipeline that the runner executes, using a generated or programmatic pipeline definition. Many tools support this: Jenkins scripted pipelines, GitLab parent-child and dynamic child pipelines, GitHub Actions reusable workflows with matrix or conditional jobs.
TRADE-OFFS, which the question explicitly asks for: the upside is DRY, consistent, low-maintenance onboarding, new repos get a correct pipeline for free. The downside is reduced transparency, the effective pipeline is not visible by reading a checked-in file, which surprises developers and complicates debugging. Generated steps are harder to reproduce locally and to audit. There are security concerns: dynamically assembling and executing steps based on repo contents can be exploited if an attacker adds a marker or a malicious template, so templates must be trusted and versioned. Detection can produce false positives, a stray Dockerfile in a docs folder triggering an unwanted build.
The mistakes people make
Describing only the happy-path detection with no discussion of the transparency, debuggability, and security costs the question asks for. Hard-coding every case instead of a template registry. Ignoring ordering and dependencies between stages.
What usually comes next
How do you let a repo override or opt out of detection? How do you version and test the templates themselves? How do you prevent a malicious repo from injecting steps? How do you make the generated pipeline observable and reproducible?
A concrete example
A detection job clones the repo, finds both a pom.xml and a Dockerfile, and emits a child pipeline with a Maven build-and-test stage followed by a container build-and-push stage. A second repo with only package.json gets a Node install, lint, test pipeline instead, all without either team writing pipeline YAML, at the cost that neither can read their full pipeline in their own repository.
Interview question
What is the most significant downside of dynamically generating CI/CD pipelines from repository contents?
- a.Pipelines can never run in parallel
- b.It always runs slower than a static pipeline
- c.It is impossible to build Docker images this way
- d.The effective pipeline is not visible in the repo, hurting transparency, debugging, and auditabilityCorrect
Why? this is the answer
Generated pipelines trade explicitness for convenience: developers cannot read their real pipeline from a checked-in file, which complicates debugging, reproduction, and security auditing. Parallelism, Docker builds, and speed are not inherently blocked.
Just read this? Test yourself on what you have been reading.
Read the original → jenkins.io
- #ci-cd
- #pipeline-as-code
- #platform-engineering
- #automation
- #dynamic-pipelines
You just looked this up. Could you explain it out loud?
That is the part interviews actually test. Tezvyn takes questions like this one and gives you what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.
We are hiring for this. Open roles that interview on ci-cd — each one lists the topics its interview covers.
See open roles