Summary: we changed IP addresses; I updated IP addresses, but waitForQualityGate() is still looking for old IP address.
I inherited a SonarQube installation (I believe 8.1) in a Windows 10 system that has worked consistently under Jenkins, including waitForQualityGate.
The SonarQube installation is on the Jenkins master, but the builds are done on a Jenkins slave.
We have needed to change IP addresses.
I have updated IP addresses:
On Jenkins master, C:\sonarqube\conf\sonar.properties (sonar.jdbc.url, the :1433 URL)
Jenkins > configuration > SonarQube servers > Server URL (:9000)
SonarQube server (at :9000) > Admin > Config > Webhooks: the Jenkins webhook
sonar-scanner.properties on the build agent: the sonar.host.url line was commented out with #, but I updated the URL anyway
The build line: SonarScanner.MSBuild.exe begin /d:sonar.host.url=
But: waitForQualityGate() fails:
script
{
// waitForQualityGate
Checking status of SonarQube task on server âSonarQubeâ
}
// script
. . .
java.net.ConnectException: Connection timed out: connect
. . .
Caused: java.lang.IllegalStateException: Fail to request
On the build agent, I checked the resulting .sonarqube/conf/SonarQubeAnalysisConfig.xml; it shows the new IP.
I have rebooted the Jenkins master
I have checked the Community for similar questions.
Any ideas where the old IP address is hiding, and how I can fix it?
Jenkins isnât waiting on a specific SonarQube IP/URL. Itâs waiting to hear from a SonarQube. You should check on the SonarQube side (Administration -> Webhooks, at project level or Administration -> Configuration -> Webhooks at global level) to see where your Webhooks are being sent and what response if any theyâre getting.
Thanks for responding. Maybe I wasnât clear earlier.
Iâm seeing this at the end of the Jenkins console output
java.net.ConnectException: Connection timed out: connect
. . .
Caused: java.lang.IllegalStateException: Fail to request http://oldIPaddress:9000/api/ce/task?id=SonarQubeID
at org.sonarqube.ws.client.HttpConnector.doCall(HttpConnector.java:212)
. . .
As I noted originally, I logged into SonarQube server (as administrator), and updated the IP address in Administration > Configuration > Webhooks. I even rebooted where it and the Jenkins master live.
But I just noticed something interesting: the old IP address that is being used references port 9000 (which would be the SonarQube server). The Webhook on the server uses port 8080 (which is the Jenkins server). I didnât modify any port numbers, so I presume this is correct.
I appreciate your help so far. Any other ideas?
Larry
Since the system is sandboxed, I am transcribing. Typos are my fault.
The build is kicked off with a PowerShell script
$msbuild = "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe"
SonarScanner.MSBuild.exe begin /k:"buildname" /d:sonar.host.url="http://newIPAddress:9000" /d:sonar.login="wholeBunchOfHexDigits"
Select-String -Path $buildPath\pathToBuildFile\buildFile.bld '(?<=%\\).*\.sln(?=")' -AllMatches ⌠(do you need more here?)
SonarScanner.MSBuild.exe end /d:sonar.login="sameHexDigitsAsAbove"
This means of calling MSBuild with SonarQube has worked successfully for over a year.
QG:
timeout(time: 30, unit: 'MINUTES') {
def qq = waitForQualityGate()
if (qq.status != 'OK') {
error "Pipeline aborted due to quality gate failure; ${qq.status}"
}
}
Output:
Quality Gate
[Pipeline] timeout
Timeout set to expire in 30 min
{
waitForQualityGate
Checking status of SonarQube task 'bunchofLettersAndDigits' on server 'SonarQube'
}
// timeout
Post stage
Iâll be honest. I have no idea where that old I.P. is set/cached/coming from (mmm⌠âcachedâ⌠you might clean out any .sonar directories you see lying around). What I can say is that that waitForQualityGate step is supposed to be picking up information from the previous step you ran withSonarQubeEnv. Except that youâre not using that because youâre passing the server info on the command line instead, as described in the Scanner for MSBuild docs. The Scanner for Jenkins suggest a slightly different structure for MSBuild analysis via Jenkins:
node {
stage('SCM') {
git 'https://github.com/foo/bar.git'
}
stage('Build + SonarQube analysis') {
def sqScannerMsBuildHome = tool 'Scanner for MSBuild 4.6'
withSonarQubeEnv('My SonarQube Server') {
bat "${sqScannerMsBuildHome}\\SonarQube.Scanner.MSBuild.exe begin /k:myKey"
bat 'MSBuild.exe /t:Rebuild'
bat "${sqScannerMsBuildHome}\\SonarQube.Scanner.MSBuild.exe end"
}
}
}
That withSonarQubeEnv part defines which of the possibly many SonarQube instances you have defined at the global level to use, so server URL and auth are picked up from there.
Thanks for your replies.
Felipe: I checked the Server base URL field; it has always been blank. I may to need to set it. Do I use the URL of the Jenkins master (which should be in Webhooks?) or the SonarQube server (:9000)?
Ann: More info â the build stage (which calls what I wrote above) looks thus
And as I noted in my first post, in Jenkins > Configure System > SonarQube servers;
Environment variables: checked
SonarQube installations: Name âSonarQubeâ (unchanged); Server URL: updated to new IP address; Server authentication token: unchanged
Maybe I need to fill in the previously empty âServer base URLâ as Felipe suggested. So which URL do I use: MyJenkinsMaster:8080 or MySonarServer:9000?
Also just noticed: on the Pipeline page, the left column that has all the quick links (âBack to Dashboardâ, âStatusâ, âBuild Nowâ (or âBuild with Parametersâ, âDelete Pipelineâ, âŚ), the âSonarQubeâ link â has the old IP address!