you end up with class with the same name as the groovy file. Inside
>> the class you can call pipeline steps and access the global variables like
>> it’s a pipeline script. However I don’t think you can have anything other
>> than a no-arg constructor.
>>
>>
>>
>>
>&
; methods you end up with class with the same name as the groovy file. Inside
> the class you can call pipeline steps and access the global variables like
> it’s a pipeline script. However I don’t think you can have anything other
> than a no-arg constructor.
>
>
>
>
>
> Rega
iel.
From: Peter Berghold
Sent: 01 December 2017 18:02
To: Jenkins Users
Subject: Define a class inside a groovy pipeline?
So I was playing around and tried something. Here's a class I defined:
class MyClass implements Serializable {
MyClass() {
}
def bark(){
sh 'echo W
So I was playing around and tried something. Here's a class I defined:
class MyClass implements Serializable {
MyClass() {
}
def bark(){
sh 'echo WOOF!'
}
}
and so I instantiate it
def mc = new MyClass()
and I access my method
mc.bark()
and I get
hudson.remoting.ProxyExceptio