Jenkins waitForQualityGate可以';t连接到Sonarcloud.io以获得质量门结果

Jenkins waitForQualityGate可以';t连接到Sonarcloud.io以获得质量门结果,jenkins,jenkins-pipeline,jenkins-groovy,sonar-runner,sonarcloud,Jenkins,Jenkins Pipeline,Jenkins Groovy,Sonar Runner,Sonarcloud,最初,我用SonarCloud.io扫描我的repo时遇到了一个问题。我使用的是sonar scanner.4.2,由于代理问题,我无法连接到SonarCloud.io,但我在jenkins文件的Environment部分中添加了sonar_scanner_OPTS='-Dhttps.proxyHost=***-Dhttps.proxyPort=***' environment { SONAR_SCANNER_OPTS='-Dhttps.proxyHost=****** -Dht

最初,我用SonarCloud.io扫描我的repo时遇到了一个问题。我使用的是sonar scanner.4.2,由于代理问题,我无法连接到SonarCloud.io,但我在jenkins文件的Environment部分中添加了sonar_scanner_OPTS='-Dhttps.proxyHost=***-Dhttps.proxyPort=***'

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:请求失败********


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

设置代理的一种方法是使用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}"
      }
   }
}

我在Jenkins中设置了代理环境,也许这不是代理问题。我尝试了您的修复,但我遇到了相同的问题:(