How to use classes in pipeline script?

397 views
Skip to first unread message

Lars Meynberg

unread,
Jun 8, 2016, 6:08:37 AM6/8/16
to Jenkins Users
We want to group some information in an object rather then have multiple variables in the main pipeline script. 
I tried to create a class (First Java then Groovy) but every time when I try to init it in the script I got following error:

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 1: unable to resolve class classes.BuildEnvironment
 @ line 1, column 1.
   import classes.BuildEnvironment

The folder looks like this
simple_pipeline.groovy
external.groovy
classes/BuildEnvironment.groovy

The pipeline setup is attached.

Maybe someone can point out what I'm doing wrong.
Pipeline_Example.zip

Lars Meynberg

unread,
Jun 8, 2016, 4:06:46 PM6/8/16
to Jenkins Users
I'm aware that there is the possibility of the workflow-cps-global-lib-plugin but I like to now if it's possible without it or is that another groovy restriction for pipeline scripts like Closures?

Sven Finsterwalder

unread,
Oct 10, 2016, 7:48:12 AM10/10/16
to Jenkins Users
I have a similar problem with an enum class.
Has anyone a solution or a hint to solve that issue.
Reply all
Reply to author
Forward
0 new messages