Groovy - Creating a sample jenkins pipeline Code Example

The code for Creating a sample jenkins pipeline

pipeline {
    agent any

    stages {
        stage('test') {
            steps {
                sh 'echo hello'
            }
        }
        stage('test1') {
            steps {
                sh 'echo $TEST'
            }
        }
        stage('test3') {
            steps {
                script {
                    if (env.BRANCH_NAME == 'master') {
                        echo 'I only execute on the master branch'
                    } else {
                        echo 'I execute elsewhere'
                    }
                }
            }
        }
    }
}
Code by IncludeHelp, on August 8, 2022 16:29
Reference: stackoverflow

Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.