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

Ten teams copy the same 80-line "build and push image" stage. What do you do?

BeginnerScenarioJenkins Shared Libraries, Credentials and Security
Answer

Situation read → Duplicated pipeline logic drifting apart.

What I'd do →

  1. Create a Git repo with vars/buildAndPush.groovy defining def call(Map cfg).
  2. Register it under Manage Jenkins > System > Global Trusted Pipeline Libraries with a default version.
  3. Call it with @Library('[email protected]') _ and buildAndPush(image: 'app', tag: env.GIT_COMMIT).

Why → One fix is delivered to every team, and versioning controls the blast radius.

Interview tip → Tag releases and pin consumers; never let everyone track main of a shared library.

All CI/CD questions

More on Jenkins Shared Libraries, Credentials and Security