Last active
September 12, 2018 15:55
-
-
Save iguoli/f4e904a1ccae91d76a58d57b0551cc77 to your computer and use it in GitHub Desktop.
Pipeline script code snippets
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
// 使用环境变量及自定义变量 | |
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