Introduction to the Workflow plugin Part 1

This post introduces Jenkins Workflow (Pipeline) basics, including staged execution and checkpoint-based restart behavior for complex delivery flows. It shows how these features improve visibility and reduce rebuild overhead when long pipelines fail midstream.

Coveros Staff

June 22, 2015

The Workflow plugin is an open source plugin (or paid plugin available with Enterprise Jenkins by Cloudbees) that solves the challenge of complex build and delivery pipelines in Jenkins, and does so by using a Groovy DSL. Packaged with the core Workflow plugin, are other supporting plugins that increase the usefulness of the Workflow plugin. The first supporting plugin is the Stages plugin which allows you to define stages as conceptual boundaries in your workflow, and allows for marking if a stage can run in concurrency or not. For example, if you have a workflow that builds your application, deploys it, and runs front end GUI tests, you could break this into three obvious stages (build, deploy, test), and might not want your deploy step to run concurrently. The DSL for this is very simple:
stage 'Build' node('build-node'){ //build your app } stage 'Deploy', concurrency: 1 node('deploy-node'){ //deploy your app } stage 'Test' node('test-node'){ //run your automated tests }
Workflow also allows for visualization of the stages, which makes it easier for developers to see where their commits have gone.

The next feature within the Workflow suite, is the idea of checkpoints. The idea of a workflow checkpoint is the same as in a video game, if you die, you can start over from the checkpoint. For example, if your automated test suite fails due to a flaky test (and the developer refuses to fix the flakiness), you could always rerun it. Of course this adds a little more complexity to our pipeline and the corresponding code would be:
stage 'Build' node('build-node'){ //build your app } steps.checkpoint('Deploy') stage 'Deploy', concurrency: 1 node('deploy-node'){ //deploy your app } steps.checkpoint('Test') stage 'Test' node('test-node'){ //run your automated tests }

This code would allow for you to either redeploy, or retest your application. This could be very useful if your application takes a very long time to build, and you don’t want to rebuild every time a deploy, or a (flaky) test fails.

There is much more to the Workflow that I have to write about, please stay tuned for the next installment!

Coveros Staff

Coveros Staff

This post represents the collective insights of the Coveros team. Our staff consists of software experts who bring deep experience in secure agile development, DevOps, testing, and software quality. Over the past 20 years, Coveros has trained more than 30,000 professionals and worked with half of the Fortune 100 companies on mission-critical software development challenges. We draw on this extensive experience to share practical insights, proven strategies, and real-world solutions that help organizations build better software faster and more securely.