Jenkins Pipeline waitForQualityGate pending 超時


請參考鏈接:http://www.iotxing.com/2019/06/12/258/jenkins-pipeline-waitforqualitygate%E8%B6%85%E6%97%B6/

 

主要是因為sonaqube的一個小bug, 需要sleep 幾秒

pipeline {
    agent any

    //任務集合,一個大的任務
    stages {
        stage('代碼獲取') {
            steps {
                checkout([$class: 'GitSCM', branches: [[name: '${git_version}']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '0f180207-47bf-20-a9-a20fd91f445f', url: 'git@gitlab.domain.com:xxx/monitor.git']]])
            }
        }
        stage('代碼質檢') {
            steps {
                withSonarQubeEnv('SonarQube') {
                    sh '/usr/local/sonar-scanner/bin/sonar-scanner -Dsonar.projectKey=html -Dsonar.projectName=${JOB_NAME} -Dsonar.sources=.'
                }
                    script {
                       timeout(1) {
                           sleep(5)
                           def qg = waitForQualityGate()
                           if (qg.status != 'OK') {
                               error "未通過SonarQube的代碼檢查,請及時修改! failure: ${qg.status}"
                           }
                       }
                   }
            }
        }
        stage('代碼構建') {
            steps {
                echo "build is ok"
            }
        }
        stage('代碼部署') {
            steps {
                sh '/usr/local/shell/pipeline_deploy_html.sh'
            }
        }
    }
    post {
        failure {
            dingTalk accessToken: 'd631ae76dabd6fabba81b1fe4a7f3d2fe3a8da8636ba72554348efe1982a', imageUrl: '', jenkinsUrl: 'http://jenkins.domain.com:8080/', message: '代碼部署失敗', notifyPeople: 'phone' 
        }
        success {
            dingTalk accessToken: 'd631ae76dabd6fabba81b1fe4a7f3d2fe3a8da8636ba725348ef71e1982a', imageUrl: '', jenkinsUrl: 'http://jenkins.domain.com:8080/', message: '代碼部署成功', notifyPeople: 'phone'
        }

    }
}

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM