Skip to content

Commit 544c127

Browse files
committed
add return this; to load-from-file
with jenkins 2.19 and workflow-cps 2.13, when `load`ing a script without `return this` at end, the result is `null` see https://jenkins.io/doc/pipeline/steps/workflow-cps/: Where `pipeline.groovy` defines functionA and functionB functions (among others) before ending with `return this;`
1 parent cff723d commit 544c127

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// If there's a call method, you can just load the file, say, as "foo", and then invoke that call method with foo(...)
22
def call(String whoAreYou) {
33
echo "Now we're being called more magically, ${whoAreYou}, thanks to the call(...) method."
4-
}
4+
}
5+
6+
return this;
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// Methods in this file will end up as object methods on the object that load returns.
22
def lookAtThis(String whoAreYou) {
33
echo "Look at this, ${whoAreYou}! You loaded this from another file!"
4-
}
4+
}
5+
6+
return this;

0 commit comments

Comments
 (0)