-
Bug
-
Resolution: Not A Defect
-
Minor
-
Tested on Jenkins docker images 1.642.4 / 2.0-beta-2
Documentation says "Internally, scripts in the vars directory are instantiated as a singleton on-demand, when used first."
Here is a very basic example to demonstrate it's not the case:
// vars/acme.groovy def setFoo(v) { this.foo = v; } def getFoo() { return this.foo; }
// src/com/foo/Zot.groovy package com.foo def printAcmeFoo() { try { echo acme.foo } catch (e){ echo "acme.foo is undefined" } }
And here is a pipeline:
import com.foo.Zot node{ acme.foo = "5" echo acme.foo; Zot z = new Zot() z.printAcmeFoo() }
Actually it shows 2 issues:
1/ scripts in the vars directory are not singletons
2/ when accessing undefined field pipeline will hang indefinitely
- is duplicated by
-
JENKINS-38795 global variables are not global singletons
-
- Resolved
-
- is related to
-
JENKINS-36673 MissingMethodException When Calling Pipeline Library Function
-
- Resolved
-
- relates to
-
JENKINS-38021 Accessing unset global variable cause master to hang
-
- Resolved
-
- links to
[JENKINS-34416] Documentation should clarify distinction between global variable access vs. plain class references
Description |
Original:
Documentation says "Internally, scripts in the vars directory are instantiated as a singleton on-demand, when used first." Here is a very basic example to demonstrate it's not the case: {{ // vars/acme.groovy }} {{ def setFoo(v) { this.foo = v; } def getFoo() { return this.foo; } }} {{ // com/foo/Zot.groovy }} {{ package com.foo def printAcmeFoo() { try { echo acme.foo } catch (e){ echo "acme.foo is undefined" } } }} And here is a pipeline: {{ import com.foo.Zot node{ acme.foo = "5" echo acme.foo; Zot z = new Zot() z.printAcmeFoo() } }} Actually it shows 2 issues: 1/ scripts in the vars directory are not singletons 2/ when accessing undefined field pipeline will hang indefinitely |
New:
Documentation says "Internally, scripts in the vars directory are instantiated as a singleton on-demand, when used first." Here is a very basic example to demonstrate it's not the case: {code:java} // vars/acme.groovy def setFoo(v) { this.foo = v; } def getFoo() { return this.foo; } {code} {{ // com/foo/Zot.groovy }} {{ package com.foo def printAcmeFoo() { try { echo acme.foo } catch (e){ echo "acme.foo is undefined" } } }} And here is a pipeline: {{ import com.foo.Zot node{ acme.foo = "5" echo acme.foo; Zot z = new Zot() z.printAcmeFoo() } }} Actually it shows 2 issues: 1/ scripts in the vars directory are not singletons 2/ when accessing undefined field pipeline will hang indefinitely |
Description |
Original:
Documentation says "Internally, scripts in the vars directory are instantiated as a singleton on-demand, when used first." Here is a very basic example to demonstrate it's not the case: {code:java} // vars/acme.groovy def setFoo(v) { this.foo = v; } def getFoo() { return this.foo; } {code} {{ // com/foo/Zot.groovy }} {{ package com.foo def printAcmeFoo() { try { echo acme.foo } catch (e){ echo "acme.foo is undefined" } } }} And here is a pipeline: {{ import com.foo.Zot node{ acme.foo = "5" echo acme.foo; Zot z = new Zot() z.printAcmeFoo() } }} Actually it shows 2 issues: 1/ scripts in the vars directory are not singletons 2/ when accessing undefined field pipeline will hang indefinitely |
New:
Documentation says "Internally, scripts in the vars directory are instantiated as a singleton on-demand, when used first." Here is a very basic example to demonstrate it's not the case: {code:java} // vars/acme.groovy def setFoo(v) { this.foo = v; } def getFoo() { return this.foo; } {code} {code:java} // com/foo/Zot.groovy package com.foo def printAcmeFoo() { try { echo acme.foo } catch (e){ echo "acme.foo is undefined" } } {code} And here is a pipeline: {code:java} import com.foo.Zot node{ acme.foo = "5" echo acme.foo; Zot z = new Zot() z.printAcmeFoo() } {code} Actually it shows 2 issues: 1/ scripts in the vars directory are not singletons 2/ when accessing undefined field pipeline will hang indefinitely |
Description |
Original:
Documentation says "Internally, scripts in the vars directory are instantiated as a singleton on-demand, when used first." Here is a very basic example to demonstrate it's not the case: {code:java} // vars/acme.groovy def setFoo(v) { this.foo = v; } def getFoo() { return this.foo; } {code} {code:java} // com/foo/Zot.groovy package com.foo def printAcmeFoo() { try { echo acme.foo } catch (e){ echo "acme.foo is undefined" } } {code} And here is a pipeline: {code:java} import com.foo.Zot node{ acme.foo = "5" echo acme.foo; Zot z = new Zot() z.printAcmeFoo() } {code} Actually it shows 2 issues: 1/ scripts in the vars directory are not singletons 2/ when accessing undefined field pipeline will hang indefinitely |
New:
Documentation says "Internally, scripts in the vars directory are instantiated as a singleton on-demand, when used first." Here is a very basic example to demonstrate it's not the case: {code:java} // vars/acme.groovy def setFoo(v) { this.foo = v; } def getFoo() { return this.foo; } {code} {code:java} // src/com/foo/Zot.groovy package com.foo def printAcmeFoo() { try { echo acme.foo } catch (e){ echo "acme.foo is undefined" } } {code} And here is a pipeline: {code:java} import com.foo.Zot node{ acme.foo = "5" echo acme.foo; Zot z = new Zot() z.printAcmeFoo() } {code} Actually it shows 2 issues: 1/ scripts in the vars directory are not singletons 2/ when accessing undefined field pipeline will hang indefinitely |
Workflow | Original: JNJira [ 170529 ] | New: JNJira + In-Review [ 183941 ] |
Component/s | New: pipeline-general [ 21692 ] |
Component/s | Original: workflow-plugin [ 18820 ] |
Link |
New:
This issue is related to |
Component/s | New: workflow-cps-global-lib-plugin [ 21714 ] | |
Component/s | Original: pipeline [ 21692 ] |
I believe this issue may also be the root cause of
JENKINS-36673as well.