Does anyone have the magic maven/gradle invocation to compile a set of jenkins pipeline DSL groovy files?
Asked
Active
Viewed 4,261 times
5
-
2Do you mean interpret it for errors, locally? – Ravindranath Barathy Oct 25 '18 at 20:20
-
1Yes, that would be one use. Another use may be to add testing. – Christian Goetze Oct 25 '18 at 20:23
-
This is what I use personally: https://jenkins.io/doc/book/pipeline/development/#linter – Ravindranath Barathy Oct 25 '18 at 20:24
-
This is only good for linting – Ravindranath Barathy Oct 25 '18 at 20:25
-
I know about that, but it seems to only understand static constructs, and we have a lot of dynamic code (basically loops which generate whole sets of pipelines). – Christian Goetze Oct 25 '18 at 20:45
-
1Maybe what you really want is to test your pipeline code locally? You may want to have a look into https://github.com/jenkinsci/JenkinsPipelineUnit or the JenkinsTestHarness: https://github.com/jenkinsci/jenkins-test-harness which actually is used by the Jenkins plugin and core developers. – Joerg S Oct 30 '18 at 05:49
-
I would like to check specifically for one error locally: `org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: General error during class generation: Method code too large!` – nroose Feb 07 '20 at 21:49
1 Answers
1
Groovy is not compiled (like C#), it is interpreted.
Depending on exactly what you are trying to test potential options are:
- Jenkins Groovy Script Console under Manage Jenkins. Note: You will need to be an Admin to be able to access this.
- Pipeline Syntax Generator. It is improving. Go to a build of Pipeline job and in the LHS menu you will see a 'Pipeline Syntax' link. Some items require you to first select
Pipeline: Steps
from the first dropdown.

Andrew Gray
- 3,593
- 3
- 35
- 62
-
I wished there was a non-interactive method, usable as a pre-merge test. – Christian Goetze Oct 26 '18 at 17:26
-
2In fact groovy is compiled into Java byte code which will be executed in the JVM. – Joerg S Oct 30 '18 at 05:45
-
@JoergS This is true, although Groovy behaves like many interpreted languages in that source files can be directly executed with the `groovy` command. – StockB Jan 31 '19 at 21:15