Skip to content

Commit c6d283f

Browse files
committed
Add a little documentation for whenChanged()
1 parent f01c9bb commit c6d283f

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

vars/whenChanged.groovy

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
whenChanged('some/path') { yourCode() } can be used to execute pipeline code in PRs only when changes are detected on paths that you specify.
3+
The specified code blocks will also always be executed during the non-PR jobs for tracked branches.
4+
5+
You have the option of passing in path prefixes, or regexes. Single or multiple.
6+
Path specifications are NOT globby, they are only prefixes.
7+
Specifying multiple will treat them as ORs.
8+
9+
Example Usages:
10+
whenChanged('a/path/prefix/') { someCode() }
11+
whenChanged(startsWith: 'a/path/prefix/') { someCode() } // Same as above
12+
whenChanged(['prefix1/', 'prefix2/']) { someCode() }
13+
whenChanged(regex: /\.test\.js$/) { someCode() }
14+
whenChanged(regex: [/abc/, /xyz/]) { someCode() }
15+
*/
16+
117
def call(String startsWithString, Closure closure) {
218
return whenChanged([ startsWith: startsWithString ], closure)
319
}

0 commit comments

Comments
 (0)