Where should Jenkinsfiles and Dockerfiles live?
⚡
Quick Answer
In each service repository alongside the code (a Jenkinsfile and Dockerfile at the repo root or service directory). This is pipeline-as-code and image-definition-as-code, versioned with the app.
Detailed Answer
Keeping the Jenkinsfile in the repo means the pipeline is reviewed, versioned, and branch-aware (a PR can change its own build), and multibranch pipelines discover it automatically. Same for the Dockerfile — the build is reproducible from the repo. Shared logic goes into a Jenkins Shared Library rather than being copy-pasted across repos.
💡
Interview Tip
Call it pipeline-as-code, mention multibranch pipelines and Shared Libraries for reuse — that is the mature setup.
jenkinsjenkinsfilepipeline-as-code