Jenkinsfiles in a repo deploy to production, and any developer with write access could edit the deploy stage in a branch. How do you prevent misuse?
AdvancedScenarioCredentials & security
Answer
Situation read → Pipeline code in a branch runs with whatever credentials it can reach.
What I'd do →
- Prod credentials live in a separate folder used by a separate deploy job whose Jenkinsfile comes from a protected platform repo, not the app repo.
- The app pipeline only publishes an artifact and triggers the deploy job with the tag.
- The deploy job uses the Authorize Project plugin and an
inputrestricted to release managers. - Branch protection and CODEOWNERS on
Jenkinsfilechanges in app repos.
Why → Separating "who writes the pipeline" from "who can deploy" is the only real fix.
Interview tip → Or mention GitOps: Jenkins has no prod credentials at all.
More on Credentials & security
What credential types does Jenkins support out of the box?BeginnerWhat is the difference between Global and System credential scope?IntermediateHow do folder-scoped credentials help multi-team controllers?IntermediateHow does Jenkins mask secrets in logs and what are its limits?AdvancedWhat authorization strategies are available?IntermediateWhat are the key permissions to understand in matrix auth?Intermediate