Interview Prep/Jenkins/Shared libraries & multibranch

Every app repo has its own pod YAML for builds, and they all drift. How do you standardize?

IntermediateScenarioShared libraries & multibranch
Answer

Situation read → Pod templates are platform concerns and belong in the library or cloud config.

What I'd do →

  1. Put standard pod definitions in resources/pods/node.yaml, maven.yaml in the shared library.
  2. Expose a step that wraps them:
    // vars/withBuildPod.groovy
    def call(String type, Closure body) {
      podTemplate(yaml: libraryResource("pods/${type}.yaml")) { node(POD_LABEL) { body() } }
    }
    
  3. Or define named templates in JCasC with a common base (inheritFrom) and let apps reference labels.
  4. Allow overrides via a merge (yamlMergeStrategy: merge()) for resources only.

Why → One place to update images, security contexts and resource requests.

Interview tip → Mention that image bumps then happen via library releases, not 100 PRs.

All Jenkins questions Roadmap: Jenkins

More on Shared libraries & multibranch