Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging Groovy scripted pipelines in Jenkins

Tags:

I'm developing Jenkins pipelines as Groovy scripts (scripted pipelines, not declarative), and having a real hard time. Jenkins is always very generic regarding syntax/semantic errors, outputting stacks like below:

groovy.lang.MissingPropertyException: No such property: caughtError for class: groovy.lang.Binding
at groovy.lang.Binding.getVariable(Binding.java:63)
at

So I have to figure where the error is completely by myself, inspecting line per line of code. Is there a better way to debug it? What you guys use to do?

like image 903
Edson Marquezani Filho Avatar asked Dec 27 '17 14:12

Edson Marquezani Filho


People also ask

Is it possible to develop jenkins pipelines as Groovy scripts?

I'm developing Jenkins pipelines as Groovy scripts (scripted pipelines, not declarative), and having a real hard time. Jenkins is always very generic regarding syntax/semantic errors, outputting stacks like below: So I have to figure where the error is completely by myself, inspecting line per line of code.

What is “pipeline-as-code” in Jenkins?

“Pipeline-as-code” is the idea to allow everyone involved in DevOps to create and maintain Jenkins pipelines. In fact, there are two ways of applying this “pipeline-as-code” principle in life: Scripted and Declarative pipelines. “Pipeline-as-code” allows Jenkins to treat pipelines as regular files.

What is the difference between declarative and scripted pipeline in Jenkins?

Where they differ however is in syntax and flexibility. Declarative: Declarative is a more recent and advanced implementation of a pipeline as a code. Scripted: Scripted was the first and traditional implementation of the pipeline as a code in Jenkins. It was designed as a general-purpose DSL (Domain Specific Language) built with Groovy.

What are some examples of Groovy concepts in Jenkins?

Closures, methods and maps are just a few examples of Groovy concepts that Jenkins leverages for its scripted pipeline syntax. While each is only briefly touched upon here, more in-depth detail can be found in the Groovy documentation.


1 Answers

I have seen this post, http://notes.asaleh.net/posts/debugging-jenkins-pipeline/ Which describe how to debug a groovy script for jenkins pipeline. it's clearly describe the steps how to do it.

like image 155
Hatim Avatar answered Sep 22 '22 23:09

Hatim