A pipeline from a fork PR should not be able to read production credentials.
IntermediateScenarioJenkins Shared Libraries, Credentials and Security
Answer
Situation read → Untrusted code running with trusted secrets.
What I'd do →
- In the GitHub/Bitbucket branch source, set trust policy to "From users with Admin or Write permission" so fork PRs build with trusted Jenkinsfile from the target.
- Bind secrets only to stages guarded by
when { branch 'main' }. - Use credentials scoped to a folder that fork builds cannot reach, and use separate, low-privilege test credentials for PR builds.
Why → A malicious PR could modify the Jenkinsfile to print secrets.
Interview tip → "Never run untrusted code with trusted secrets" applies to every CI system.
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?BeginnerThe team wants the Jenkins configuration reproducible and reviewable. What tooling do you use?Intermediate