Hi,
I have a global library class, HelperFunction, which includes a getKeySet
function.
package mylib
@NonCPS def getKeySet(m)
{
def key_set = m.keySet()
key_set.toArray(new String[key_set.size()])
}
return this
Now I use this function in two places.
One is in a script which is loaded by my JenkinsFile, using a load step
It (in cut down form) looks like this
#!groovy
HelperFunction = new mylib.HelperFunction()
@NonCPS def includeTable(build_types, include_string, exclude_string)
{
def platforms = HelperFunction.getKeySet(build_types.generators)
// Rest of function
}
return this
this works, as does this alternative
#!groovy
@NonCPS def includeTable(build_types, include_string, exclude_string)
{
def HelperFunction = new mylib.HelperFunction()
def platforms = HelperFunction.getKeySet(build_types.generators)
// Rest of function
}
return this
It is also used in a Folder library file which contains a class
instantiated as
myBuildClasses = new mylib.MyBuildClasses()
The following works fine, much as in the above example
package mylib
@NonCPS def buildTableHtml(caption, build_types, include_table)
{
def HelperFunction = new mylib.HelperFunction()
def platforms = HelperFunction.getKeySet(build_types.generators)
// Rest of function
}
return this
but this
package mylib
HelperFunction = new mylib.HelperFunction()
@NonCPS def buildTableHtml(caption, build_types, include_table)
{
def platforms = HelperFunction.getKeySet(build_types.generators)
// Rest of function
}
return this
results in
you tried to assign a value to the class 'myLib.HelperFunction'. Do you
have a script with this name?
The good news is I can work around this issue to get what I need to work
working, the bad news is, I don't understand what is going on. Pretty much
the same code is acting very differently.
Could somebody please clarify it to me?
--
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/34b453c3-08b5-484f-8ca3-93dc16c178bc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.