waitForQualityGate无法连接到Sonarcloud.io以获得质量门结果

问题描述 投票:0回答:1

我最初有一个问题,无法使用Sonar-scanner使用SonarCloud.io扫描我的仓库。4.2由于代理问题,我无法连接到SonarCloud.io,但我通过添加SONAR_SCANNER_OPTS ='-Dhttps.proxyHost进行了修复= ****** -Dhttps.proxyPort = ****'在我的jenkins文件的“环境”部分中。

environment {
        SONAR_SCANNER_OPTS='-Dhttps.proxyHost=****** -Dhttps.proxyPort=****'
}

  stage('SonarCloud analysis') {
    withSonarQubeEnv('My SonarQube Cloud') {
      sh 'mvn clean package sonar:sonar'
    }
  }
}
stage("Quality Gate"){
  timeout(time: 1, unit: 'HOURS') {
    def qg = waitForQualityGate() 
    if (qg.status != 'OK') {
      error "Pipeline aborted due to quality gate failure: ${qg.status}"
    }
  }
} 

现在我有同样的问题,但是函数waitForQualityGate()返回错误

下面发现错误:

java.net.SocketException:连接重置原因:java.lang.IllegalStateException:无法请求https://sonarcloud.io/api/ce/task?id= ********

我如何使用该功能设置代理,或者这可能是另一个问题。

jenkins jenkins-pipeline jenkins-groovy sonar-runner sonarcloud
1个回答
0
投票

设置代理的一种方法是,您可以使用Env包装步骤并在那里设置代理

withEnv(["HTTP_PROXY=${proxyHost}:${proxyPort}",
         "HTTPS_PROXY=${proxyHost}:${proxyPort}") {
      timeout(time: 1, unit: 'HOURS') {
      def qg = waitForQualityGate() 
      if (qg.status != 'OK') {
        error "Pipeline aborted due to quality gate failure: ${qg.status}"
      }
   }
}
© www.soinside.com 2019 - 2024. All rights reserved.