Jenkins-Pipline(1)

/ jenkins / 没有评论 / 1133浏览

setting

简单点,我是直接到Pipline设置,点击 Pipeline Syntax 复制下来需要的语法

code

pipeline {
    agent any
    stages {
        stage('Checkout') {
            steps {
                echo 'Checkout'
                checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '500378f5-a6e4-4255-984e-61537fe0e455', url: 'git@gitlab.aniu.so:aniu-yunwei/game-of-life.git']]])
            }
        }        
        stage('Build') {
            steps {
                echo 'Build'
                sh 'mvn clean install' # 可以用自己的 mvn clean deploy + 参数替代
            }
        }
        stage('Test') {
            steps {
                echo 'Test'
                sh 'mvn clean verify sonar:sonar' # 此处可以使用mvn test替代,笔者这步是检测代码的质量同步到自己的代码质量检测平台。
            }
        }
        stage('Deploy') {
            steps {
                echo 'Deploe'
                sh 'mvn clean deploy'  # 此处调用脚本或者ansible、saltstak,部署到远程
            }
        }
    }
}

test

pipeline {
    agent any
    stages {
        stage('Checkout') {
            steps {
                echo 'Checkout/setup1'
                build job: 'slave_node', quietPeriod: 3
            }
        }        
        stage('Build') {
            steps {
                echo 'Building'
                build job: 'slave_java', quietPeriod: 3
            }
        }
        stage('Test') {
            steps {
                echo 'Building'
                build job: 'slave_java', quietPeriod: 3
            }
        }
        stage('Deploy') {
            steps {
                echo 'Building'
                build job: 'slave_java', quietPeriod: 3
            }
        }
    }
}

demo

output