• jenkins pipeline


    jenkins pipeline 基本模式

    pipeline {
        agent any
    
        //任务集合,一个大的任务
        stages {
            stage('代码获取') {
                steps {
                    echo "get code is ok"
                }
            }
            stage('代码质检') {
                steps {
                    echo "get code is ok"
                }
            }
            stage('代码构建') {
                steps {
                    echo "build is ok"
                }
            }
            stage('代码部署') {
                steps {
                    echo "deploy is ok"
                }
            }
        }
    }
    pipeline {
        agent any
    
        //任务集合,一个大的任务
        stages {
            stage('代码获取') {
            steps {
            checkout([$class: 'GitSCM', branches: [[name: '${git_version}']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '0f180207-47af-4820-a956-a20fdd1f445f', url: 'git@gitlab.abc.com:/api.git']]])
                }
            }
            stage('代码质检') {
                steps {
                    withSonarQubeEnv('SonarQube') {
                        sh '/usr/local/sonar-scanner/bin/sonar-scanner -Dsonar.projectKey=stg-api -Dsonar.projectName=${JOB_NAME} -Dsonar.sources=. -Dsonar.java.binaries=target/'
                    }
                        script {
                           timeout(3) {
                               sleep(10)
                               def qg = waitForQualityGate()
                               if (qg.status != 'OK') {
                                   error "未通过SonarQube的代码检查,请及时修改! failure: ${qg.status}"
                               }
                           }
                       }
                }
            }
            stage('代码构建') {
                steps {
                    sh '/bin/mvn clean install'
                }
            }
            stage('代码部署') {
                steps {
                    sh '/usr/local/shell/stg-api.sh'
                }
            }
        }
        post {
            failure {
                dingTalk accessToken: 'd631ae76dabd6fabba81b1fe4a7f3d2fe3a8da8636ba72554348ef71e1982a2a', imageUrl: 'http://jenkins.abc.com/dingding_fail.png', jenkinsUrl: 'http://jenkins.abc.com:8080/', message: '代码部署失败', notifyPeople: 'phone' 
            }
            success {
                dingTalk accessToken: 'd631ae76dabd6fabba81b1fe4a7f3d2fe3a8da8636ba72554348ef71e1982a2a', imageUrl: 'http://jenkins.abc.com/dingding_OK.png', jenkinsUrl: 'http://jenkins.abc.com:8080/', message: '代码部署成功', notifyPeople: 'phone'
            }
    
        }
    }
  • 相关阅读:
    vue项目index.html , main.js的关系
    vue项目是如何加载入口文件main.js的
    解决Mysql密码修改后不能登录的问题
    解决IDEA右侧maven不显示方法
    (转)sql语句定义和执行顺序
    关于我
    css中好用的clamp()函数
    vue中子组件使用$emit传值的种种情况
    我的大学 -詹书庭
    自定义组件使用v-model
  • 原文地址:https://www.cnblogs.com/faberbeta/p/jenkins003.html
Copyright © 2020-2023  润新知