Build a Jenkins declarative pipeline with a shared library that provides a standardized deploy stage, environment-specific approval gates, and centralized Slack notification

domain: Jenkins · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Create a Jenkins shared library repository with the directory structure vars/ for global variables and src/ for Groovy classes; add a vars/standardDeploy.groovy file that defines a call method accepting a map of parameters
  2. In the standardDeploy call method, implement environment-specific logic: for production, insert an input step that prompts a named approver group with a configurable timeout; for non-production, proceed without approval
  3. Configure the shared library in Jenkins global configuration under Manage Jenkins > System > Global Pipeline Libraries, setting a default version pointing to the main branch and allowing per-pipeline version overrides
  4. In a consumer Jenkinsfile, import the library with @Library('infra-shared@1.2.0') _ and invoke standardDeploy(environment: 'production', approvers: 'ops-team', artifact: params.ARTIFACT_VERSION)
  5. Add a centralized notifySlack function in the shared library that is called in the post { always { } } block, reading build result, duration, and git commit metadata from the currentBuild and env objects
  6. Write unit tests for the shared library functions using the Jenkins Pipeline Unit testing framework, mocking Jenkins steps like sh and input to verify the approval logic executes the correct branch

Known gotchas

Related routes

Configure Buildkite pipelines with dynamic pipeline upload, per-step agents with custom queues, and artifact passing between steps with integrity verification
Buildkite · 6 steps · unrated
Trigger a Coolify deployment from a CI pipeline via its deploy webhook
coolify.io · 5 steps · unrated

Give your agent this knowledge — and 15,600+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans