Interview Prep/Jenkins/Shared libraries & multibranch

PRs from forks must be built, but the security team is worried about secrets. How do you configure it?

AdvancedScenarioShared libraries & multibranch
Answer

Situation read → Fork PRs run untrusted code; the Jenkinsfile and build scripts can be attacker-controlled.

What I'd do →

  1. Set fork PR trust to "From users with Admin or Write permission" (or Nobody), so untrusted forks run the target branch's Jenkinsfile.
  2. Remember the target Jenkinsfile still runs the fork's code (tests, build scripts), so do not bind any secrets in PR stages.
  3. Run PR builds on a separate, isolated agent pool (different namespace or cluster, no network to internal systems).
  4. Require a maintainer comment or label to trigger builds for first-time contributors.

Why → Trust settings protect the pipeline definition, not the code it executes; isolation protects the rest.

Interview tip → This "trusted Jenkinsfile, untrusted code" distinction is what interviewers want to hear.

All Jenkins questions Roadmap: Jenkins

More on Shared libraries & multibranch