Created
July 31, 2024 06:11
-
-
Save Storager/465c486b401fc55036ecaa6025df696a to your computer and use it in GitHub Desktop.
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
| def buildResult | |
| pipeline { | |
| agent any | |
| parameters { | |
| booleanParam(name: 'makeSuccessful', defaultValue: false, description: 'Make it successful') | |
| } | |
| stages { | |
| stage('Build') { | |
| steps { | |
| echo 'Hello World' | |
| // currentBuild.result == null here | |
| } | |
| } | |
| stage('Make Successful') { | |
| when { | |
| expression { | |
| return params.makeSuccessful | |
| } | |
| } | |
| steps { | |
| script { | |
| buildResult = 'SUCCESS' | |
| } | |
| echo buildResult | |
| } | |
| } | |
| stage('Make notBuilt') { | |
| when { | |
| expression { | |
| return ! params.makeSuccessful | |
| } | |
| } | |
| steps { | |
| script { | |
| buildResult = 'NOT_BUILT' | |
| } | |
| echo buildResult | |
| } | |
| } | |
| } | |
| post { | |
| always { | |
| script { | |
| currentBuild.result = buildResult | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment