Last active
May 24, 2019 06:40
Star
You must be signed in to star a gist
Is it possible to do _this_ in Jenkins pipeline?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TODO: What does call actually return? Is it void? | |
def call(Closure body) { | |
// Call the body of the block and capture it into variables | |
Map<String, Object> config = [:] | |
body.resolveStrategy = Closure.DELEGATE_FIRST | |
body.delegate = config | |
body() | |
Closure template = (Closure) config.template | |
List<List<Object>> matrix = (List<List<Object>>) config.matrix | |
template.resolveStrategy = Closure.DELEGATE_FIRST | |
for (List<Object> oneRun : matrix) { | |
template.delegate = oneRun | |
template() | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pipeline { | |
// ... | |
stages { | |
// ... | |
customMatrix { | |
matrix [name: 'debian', prettyName: 'Debian'], | |
[name: 'ubuntu', prettyName: 'Ubuntu'], | |
[name: 'centos', prettyName: 'CentOS'], | |
[name: 'macos', prettyName: 'macOS'], | |
[name: 'windows', prettyName: 'Windows'] | |
template { | |
stage("Test on ${prettyName}") { | |
agent { | |
label name | |
} | |
steps { | |
unstash 'compile-artifacts' | |
unstash 'dot-gradle' | |
gradle tasks: 'check', switches: '--stacktrace' | |
} | |
post { | |
always { | |
junit '*/build/test-results/**/*.xml' | |
} | |
} | |
} | |
} | |
} | |
// ... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment