File tree Expand file tree Collapse file tree 3 files changed +42
-0
lines changed
global-library-examples/global-function Expand file tree Collapse file tree 3 files changed +42
-0
lines changed Original file line number Diff line number Diff line change 1+ #! groovy
2+
3+ // Loads the standardBuild method from workflowLibs.git/vars/standardBuild.groovy
4+ // and invokes it.
5+ standardBuild {
6+ environment = ' golang:1.5.0'
7+ mainScript = '''
8+ go version
9+ go build -v hello-world.go
10+ '''
11+ postScript = '''
12+ ls -l
13+ ./hello-world
14+ '''
15+ }
Original file line number Diff line number Diff line change 1+ # Synopsis
2+ An example of how to define a global function for the Workflow DSL on
3+ your Jenkins master using the global CPS library.
4+
5+ # Credit
6+
7+ This comes from the [ CloudBeers demo] ( https://github.com/cloudbeers/multibranch-demo ) .
Original file line number Diff line number Diff line change 1+ // See https://github.com/jenkinsci/workflow-plugin/tree/master/cps-global-lib#defining-global-functions
2+
3+ // The call(body) method in any file in workflowLibs.git/vars is exposed as a
4+ // method with the same name as the file.
5+ def call (body ) {
6+ def config = [:]
7+ body. resolveStrategy = Closure . DELEGATE_FIRST
8+ body. delegate = config
9+ body()
10+ stage ' checkout'
11+ node {
12+ checkout scm
13+ stage ' main'
14+ docker. image(config. environment). inside {
15+ sh config. mainScript
16+ }
17+ stage ' post'
18+ sh config. postScript
19+ }
20+ }
You can’t perform that action at this time.
0 commit comments