Build a Jenkins declarative pipeline with a shared library that provides a standardized deploy stage, environment-specific approval gates, and centralized Slack notification
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
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
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
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)
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
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
Shared library code runs in a Groovy sandbox by default; methods that call Jenkins internals or use non-whitelisted classes require script approval in the Jenkins script approval UI, and new library versions may introduce newly sandboxed calls
The input step in a shared library call blocks the Jenkins executor thread for the duration of the approval wait; configure the pipeline to release the executor using a lock or agent none block around the input step to avoid consuming executors while waiting
Shared library versions pinned with @Library('name@version') refer to Git tags or branch names; floating branch references like main mean the library is pulled at pipeline start time and mid-pipeline updates do not take effect until the next build
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp