Last active
December 27, 2019 05:14
-
-
Save lepffm/a50d19bbaa17a38d09b04647e51b0471 to your computer and use it in GitHub Desktop.
How to use variable in post directives of Jenkins pipeline example
This file contains hidden or 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
/* | |
jenkins pipeline 의 post directive 에서는 어떤 이유로인지 | |
전역 또는 stage 에서 사용했던 변수나 환경변수의 변경된 값에 접근하지 못합니다. | |
다양하게 시도해본 결과 트릭인듯 하지만 | |
currentBuild.displayName 또는 currentBuild.description 을 이용하여 처리 결과를 저장하여 | |
post 단계에서 slack 등의 툴에 동적인 정보를 전달할 수 있습니다. | |
---- | |
description: If you want to use variable on 'post' directives by storing the result message | |
according to the processing of a specific stage, | |
you can use currentBuild.displayName or currentBuild.description. | |
#displayName // normally #123 | |
#description // additional information about the build | |
*/ | |
pipeline { | |
agent any | |
stages{ | |
stage('test'){ | |
steps{ | |
script{ | |
def my_variable = 'variable_value' | |
currentBuild.description = ' stage '+my_variable | |
} | |
} | |
} | |
} | |
post { | |
always { | |
println "send slack to this message from " + currentBuild.description | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment