Interview Prep/Jenkins/Shared libraries & multibranch

How would you add a common post-build step (send build metrics) to every pipeline on the controller?

AdvancedScenarioShared libraries & multibranch
Answer

Situation read → Cross-cutting concern; editing every Jenkinsfile does not scale.

What I'd do →

  1. Prefer platform-level collection: the OpenTelemetry or Prometheus plugin captures build durations and results for all jobs without pipeline changes.
  2. For custom data, add it to the shared pipeline template's post { always { } }.
  3. For pipelines not using the template, an implicitly loaded library step can be called from a pipeline-level hook only if included, so combine with adoption tracking.

Why → Plugins observe all builds centrally; templates add custom logic where needed.

Interview tip → Mention OpenTelemetry tracing pipelines in Jaeger or Grafana Tempo.

All Jenkins questions Roadmap: Jenkins

More on Shared libraries & multibranch