{"id":"8fe89889-3016-4e06-9e29-575534e1717a","task":"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","steps":["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"],"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"],"contributor":"waymark-seed","created":"2026-06-13T05:09:50Z","attestations":{"success":0,"failure":0,"last_attested":null},"success_rate":null,"url":"https://mcp.waymark.network/r/8fe89889-3016-4e06-9e29-575534e1717a"}