Skip to content

Instantly share code, notes, and snippets.

@darinpope
Last active December 20, 2023 23:38
Show Gist options
  • Save darinpope/e790afd99c15d48eef4a794d82356cdb to your computer and use it in GitHub Desktop.
Save darinpope/e790afd99c15d48eef4a794d82356cdb to your computer and use it in GitHub Desktop.

Gist for https://youtu.be/XM0nuRJMglI

Pipeline Definitions

job-1

pipeline {
    agent any
    stages {
        stage('Hello') {
            steps {
                echo 'this is the echo step'
            }
            post {
                success {
                    echo 'this is the stage post message'
                }
            }
        }
    }
}

job-2

pipeline {
    agent any
    stages {
        stage('Hello') {
            steps {
                echo 'this is the echo step'
            }
            post {
                success {
                    echo 'this is the stage post success message'
                }
            }
        }
    }
    post {
        success {
            echo 'this is the overall post success message'
        }
        failure {
            echo 'this is the overall post failure message'
        }
    }
}

job-3

pipeline {
    agent any
    stages {
        stage('Hello') {
            steps {
                echo 'this is the echo step'
            }
            post {
                success {
                    echo 'this is the stage post success message'
                }
            }
        }
    }
    post {
        success {
            echo 'this is the overall post success message'
        }
        failure {
            echo 'this is the overall post failure message'
        }
        cleanup {
            echo 'this is the overall post cleanup message'
        }
    }
}

job-4

pipeline {
    agent any
    stages {
        stage('Hello') {
            steps {
                sh 'false'
            }
            post {
                success {
                    echo 'this is the stage post success message'
                }
            }
        }
    }
    post {
        success {
            echo 'this is the overall post success message'
        }
        failure {
            echo 'this is the overall post failure message'
        }
        cleanup {
            echo 'this is the overall post cleanup message'
        }
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment