Skip to content

Instantly share code, notes, and snippets.

@Storager
Created July 31, 2024 06:11
Show Gist options
  • Select an option

  • Save Storager/465c486b401fc55036ecaa6025df696a to your computer and use it in GitHub Desktop.

Select an option

Save Storager/465c486b401fc55036ecaa6025df696a to your computer and use it in GitHub Desktop.
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