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 →
- Prefer platform-level collection: the OpenTelemetry or Prometheus plugin captures build durations and results for all jobs without pipeline changes.
- For custom data, add it to the shared pipeline template's
post { always { } }. - 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.
More on Shared libraries & multibranch
A shared library change merged to `main` broke 200 pipelines within minutes. How do you prevent a repeat?IntermediateYou want to test a library branch against a real app pipeline without affecting anyone. How?BeginnerEvery app repo has its own pod YAML for builds, and they all drift. How do you standardize?IntermediateSecurity wants every pipeline to run a secret scan, even if teams forget to add it. How?AdvancedA multibranch project has 600 stale branch jobs and the folder page takes 30 seconds to load. What do you do?BeginnerA new org with 150 repositories wants Jenkins builds for every repo with a Jenkinsfile, without tickets to the platform team. What do you set up?Intermediate