So, what is the proper way to initialize the fields in the "Global
Variables" found in the /vars dir in library code?
I know it is supposed to be a singleton instantiated on first call, and I
know I can SET new fields by just setting them, but what if I want them to
have default value when object is created? Something like:
// vars/myListAdder.groovy
def myList = []
def call(item){
this.myList << item
}
I would expect this to work, but it doesn't as it cannot find myList defined
I worked around it for now by using a try/catch to initialize myList on
first call, but that seems wrong. There has got to be a proper way to do
this, but I am not sure what it is - nothing I tried seems to work
Thanks,
-M
--
You received this message because you are subscribed to the Google Groups
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-users/14133e6e-b137-43df-92d4-d315b3d19068%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.