脚本式

node {
    stage('Build') {
       echo 'Building...'
    }
    stage('Test') {
        echo 'Testing...'
    }
    stage('Deploy') {
        echo 'Deploying...'
    }
}

声明式

pipeline{ 
        agent any
        stages { 
            stage('Build') { 
                steps { 
                    echo 'Building' 
                    } 
                } 
            stage('Test') { 
                steps { 
                    echo 'Testing' 
                    } 
                }
            stage('Deploy - Production') { 
                steps {
                     echo 'Deploy' 
                    }
                } 
            } 
        post { 
            always { 
                echo 'One way or another, I have finished' deleteDir() /* clean up our workspace */ 
                } 
            success { 
                echo 'I succeeeded!' 
                } 
            unstable { 
                echo 'I am unstable :/'
                } 
            failure { 
                echo 'I failed :(' 
                } 
            changed { 
                echo 'Things were different before...'
                } 
            } 
        }

5 对 “Jenkins最基本的pipeline模板”的想法;

发表评论

邮箱地址不会被公开。