Skip to content

Instantly share code, notes, and snippets.

@iguoli
Last active September 12, 2018 15:55
Show Gist options
  • Save iguoli/f4e904a1ccae91d76a58d57b0551cc77 to your computer and use it in GitHub Desktop.
Save iguoli/f4e904a1ccae91d76a58d57b0551cc77 to your computer and use it in GitHub Desktop.
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