Developers can edit the Jenkinsfile in a PR to disable the security scan stage. How do you prevent it?
AdvancedScenarioJenkins Shared Libraries, Credentials and Security
Answer
Situation read → The pipeline is controlled by the people it is meant to police.
What I'd do →
- Make mandatory stages part of a shared-library "golden pipeline" that teams call, e.g.
standardPipeline(config). - Protect the Jenkinsfile and the library with CODEOWNERS and branch protection.
- Add a required status check that runs the scan independently from the repo's own pipeline.
- Verify in the admission or deploy step that the artifact carries a scan attestation.
Why → Controls must live outside the code under review.
Interview tip → Attestation checked at deploy time is the unbypassable control.
More on Jenkins Shared Libraries, Credentials and Security
Ten teams copy the same 80-line "build and push image" stage. What do you do?BeginnerA shared library change broke 50 pipelines at once. How do you prevent a repeat?AdvancedA pipeline needs an AWS secret key and a DB password. How do you provide them without exposing them in logs?BeginnerCredentials are stored in Jenkins; the security team wants no long-lived cloud keys at all.AdvancedA developer asks for admin access to Jenkins to "fix their job". How do you handle it?BeginnerA pipeline from a fork PR should not be able to read production credentials.Intermediate