https://github.com/jenkinsci/workflow-cps-global-lib-plugin#defining-global-variables
#vars/variables.groovy
def setFoo(f) {
this.foo = f
}
def isFoo() {
return this.foo
}
#src/com/company/ci/Build.groovy
void execute() {
def foo = false
if (env.BRANCH_NAME.equals("master")) {
foo = true
}
variables.setFoo(foo)
}
#Jenkinsfile
def build = new com.company.ci.Build()
build.execute()
def foo = variables.isFoo()
if (foo) {
println "We got foo"
}
groovy.lang.MissingPropertyException: No such property: foo for class:
variables
Possible solutions: foo
If I use variables.foo or if I change isFoo() to getFoo() it calls getFoo
countless times and hangs.
I am not sure what I am doing wrong here. Any clues?
I have no problem accessing variables.getFoo() within Build.groovy, but not
in the Jenkinsfile afterwards.
--
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/58e78e00-7387-4636-9bdf-5bbee5147219%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.