Interview Prep/Jenkins/Credentials & security

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 →

  1. 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.
  2. The app pipeline only publishes an artifact and triggers the deploy job with the tag.
  3. The deploy job uses the Authorize Project plugin and an input restricted to release managers.
  4. Branch protection and CODEOWNERS on Jenkinsfile changes 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.

All Jenkins questions Roadmap: Jenkins

More on Credentials & security