Interview Prep/CI/CD/Jenkins Shared Libraries, Credentials and Security

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 →

  1. 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.
  2. Bind secrets only to stages guarded by when { branch 'main' }.
  3. 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.

All CI/CD questions

More on Jenkins Shared Libraries, Credentials and Security