pipeline {
agent none
stages {
stage('Test') {
steps {
script {
def testStages = [:]
testStages['success1'] = createStage('success1', 1)
testStages['success2'] = createStage('success2', 30)
testStages['unstable'] = createStage('unstable', 5)
testStages['failure'] = createStage('failure', 10)
parallel testStages
}
}
}
}
}
def createStage(String status, int sleep) {
return {
node(label: 'small') {
//stage(status) {
try {
sh "sleep ${sleep}"
if (status.startsWith('success')) {
writeFile file: 'report.xml', text: """\
""".stripIndent()
} else if (status.startsWith('unstable')) {
writeFile file: 'report.xml', text: '''\
'''.stripIndent()
} else {
writeFile file: 'report.xml', text: '''\
'''.stripIndent()
sh 'missingCommand'
}
} finally {
junit testResults: 'report.xml'
}
echo 'hello'
//}
}
}
}