1

I had initially an issue to scan my repo with SonarCloud.io i am using sonar-scanner.4.2 i was unable to connect to SonarCloud.io due to a proxy issues but i fixed it in adding SONAR_SCANNER_OPTS='-Dhttps.proxyHost=****** -Dhttps.proxyPort=****' in environement section in my jenkins file.

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}"
    }
  }
} 

Now i have the same issue but with the function waitForQualityGate() return error

Below find the error:

java.net.SocketException: Connection reset Caused: java.lang.IllegalStateException: Fail to request https://sonarcloud.io/api/ce/task?id=********

How do i to set the proxy with the function or maybe this is another issue.

1 Answers1

0

One way to set proxy is you can wrap the step withEnv and set the proxy there

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}"
      }
   }
}
Pankaj Saini
  • 1,493
  • 8
  • 13