Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Pipeline script code snippets
// 使用环境变量及自定义变量
node {
stage('test') {
withEnv(['book=abc, number=123']) {
sh 'env'
book_number = sh(returnStdout: true, script: '''echo ${book}-${number}''')
echo "book number is ${book_number}"
println "book number string length is ${book_number.length()}"
book_number = book_number.trim()
println "book number string length after trim is ${book_number.length()}"
assert book_number == "abc-123"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment