Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Tips to Debug Jenkins v2.x Pipeline Script(s), Part 1

DZone 's Guide to

Tips to Debug Jenkins v2.x Pipeline Script(s), Part 1

Check out this simple explanation of these three features that will help you with your Jenkins pipeline.

· DevOps Zone ·
Free Resource

Introduction

In this series of posts, I wish to share (and learn from their feedback) with the community, some of the ways and methods to debug Groovy-DSL scripts used in Jenkins v2.x Pipeline-as-code.

Replay

This feature enables iterative development of the pipeline script. For beginners, it's a great feature as they can try out various possibilities before submitting the working version of the script for peer code review.

Select the build job from the Jenkins project that you wish to replay. devtest-pipeline is the project in this screenshot and we can choose to click the Replay option available for job #362.

Replay


"Show Me Red," a.k.a. Fix the Syntax Errors

On selecting the Replay option, Jenkins opens up a simple in-line editor as shown below.

This screenshot shows the pipeline-as-code script with line 7 marked by a white colored "X" inside the red square box. Such error pointer(s) (it's my lingua franca) are enabled by the Jenkins Pipeline's suite of plugins. For the sake of this example, I induced the error pointer, by removing the closing double quote at the end of the println  statement.

Error pointer

This provision (error pointer) is quite handy when you are in the process of writing such pipeline-as-code Groovy-DSL scripts — either scripted or declarative.

Easy on The Eyes

This is not a technical one but will help to avoid silly mistakes, like, missing quote(s) or typo errors.

With the Replay option making available a simple editor, the default size of that editor can be quite small and compact. However, there is no lock-in with regard to the real estate of the editor, hovering the mouse cursor on the extreme right-hand side bottom of the editor brings up (single or double headed) an arrow that helps you to resize the shape of the editor.

Resize the editor


Topics:
jenkins ,pipeline as code ,jenkins scripts ,syntax errors ,devops

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}