← All projects

Building Jenkins Shared Library

Part 1

Building Jenkins Shared Library

Jenkins shared library: Why a shared library - Part 1

~5 min read Most of my projects have a Jenkinsfile, and over time they've started to look alike. The finance system, the inventory system and the identity system each carry their own copy of a Sync blog stage - the one that publishes the project's blog/*.md posts to Ghost. The three copies are the same block of Groovy: a when { branch 'main' } guard, a catchError that marks the stage UNSTABLE instead of failing the build, two Ghost credentials, and a small shell function that runs the blog-sync
Andrew Townsend
Andrew Townsend
2 min read

Part 2

Building Jenkins Shared Library

Jenkins shared library: Extracting the Sync blog stage - Part 2

~6 min read With the scaffold in place, the first real candidate was obvious: the Sync blog stage that appears, near enough verbatim, in three Jenkinsfiles. This post is about what I moved into the library, what I deliberately left behind, and the two options I gave the new step. What the stage does Reading the three copies side by side, the work they do is the same: 1. Take two Secret text credentials from Jenkins, ghost-url and ghost-admin-key. 2. Run blog-sync --apply, which creates mi
Andrew Townsend
Andrew Townsend
2 min read