admin管理员组文章数量:1313146
I have a Visual Studio .NET project that is engaged to an Azure project, and the pipeline build is configured within a container like below:
stages:
- stage: buildStage
displayName: 'Build'
jobs:
- job: XXXXX
displayName: 'XXXX'
pool:
name: XXXXX
container:
image: XXXX
workspace:
clean: all
.........
It contains a SonarQubePrepare@6
task likes below:
- task: SonarQubePrepare@6
displayName: 'SonarQube prepare'
inputs:
SonarQube: 'SonarQube-$(System.TeamProject)'
scannerMode: 'CLI'
configMode: 'file'
projectKey: 'XXXX'
.........
However the pipeline builds were always failed with the below error message:
[error][SQ] API GET '/api/server/version' failed, error is request to failed, reason: getaddrinfo ENOTFOUND xxx-sonarqube.azurewebsites.
Someone advised that it is because proxy setting is NOT configured for the container to connect to the SonarQube server.
I am not sure what is the root cause of the above issue. Could anyone please advise? Thanks a lot!
New update on 17 Feb 2025 --------------------
Thanks for all the replies. I have combined all the suggestions and am very close to the final, but just a gap I think.
First, within the container the task can definitely retrieve the proxy setting of the agent host. I can see on the log that the proxy server and port are all displayed.
Then, after importing two .cer certificate files using the Import-Certificate PS command, the task can definitely connect to the Sonarqube server via the proxy. The task uses the invoke-webrequest PS command and successfully get the version number from the link. Hence that is an issue regarding trusted certificates.
HOWEVER, the SonarQubePrepare is still failed with the same error message as my first attempt. It seems to be a problem regarding certificates. I have tried many times but still can't find a manner to let the SonarQubePrepare task refering to those two .cer certificate files.
Any suggestions?
I have a Visual Studio .NET project that is engaged to an Azure project, and the pipeline build is configured within a container like below:
stages:
- stage: buildStage
displayName: 'Build'
jobs:
- job: XXXXX
displayName: 'XXXX'
pool:
name: XXXXX
container:
image: XXXX
workspace:
clean: all
.........
It contains a SonarQubePrepare@6
task likes below:
- task: SonarQubePrepare@6
displayName: 'SonarQube prepare'
inputs:
SonarQube: 'SonarQube-$(System.TeamProject)'
scannerMode: 'CLI'
configMode: 'file'
projectKey: 'XXXX'
.........
However the pipeline builds were always failed with the below error message:
[error][SQ] API GET '/api/server/version' failed, error is request to https://xxx-sonarqube.azurewebsites/api/server/version failed, reason: getaddrinfo ENOTFOUND xxx-sonarqube.azurewebsites.
Someone advised that it is because proxy setting is NOT configured for the container to connect to the SonarQube server.
I am not sure what is the root cause of the above issue. Could anyone please advise? Thanks a lot!
New update on 17 Feb 2025 --------------------
Thanks for all the replies. I have combined all the suggestions and am very close to the final, but just a gap I think.
First, within the container the task can definitely retrieve the proxy setting of the agent host. I can see on the log that the proxy server and port are all displayed.
Then, after importing two .cer certificate files using the Import-Certificate PS command, the task can definitely connect to the Sonarqube server via the proxy. The task uses the invoke-webrequest PS command and successfully get the version number from the https://xxx-sonarqube.azurewebsites/api/server/version link. Hence that is an issue regarding trusted certificates.
HOWEVER, the SonarQubePrepare is still failed with the same error message as my first attempt. It seems to be a problem regarding certificates. I have tried many times but still can't find a manner to let the SonarQubePrepare task refering to those two .cer certificate files.
Any suggestions?
Share Improve this question edited Feb 17 at 11:59 John Z asked Jan 31 at 7:04 John ZJohn Z 112 bronze badges 5 |1 Answer
Reset to default 0[error][SQ] API GET '/api/server/version' failed, error is request to https://xxx-sonarqube.azurewebsites/api/server/version failed, reason: getaddrinfo ENOTFOUND xxx-sonarqube.azurewebsites.
The error indicates it's not able to connect the site.
Firstly, to use the container
, you should put it align with pool
, it's same level. It won't work if you put it inside the pool definition.
stages:
- stage: buildStage
displayName: 'Build'
jobs:
- job: testjob
displayName: 'testjob'
pool:
name: 'xxxxx'
container: mcr.microsoft/windows/servercore:ltsc2019 # align with pool
workspace: # align in same way
clean: all
You can refer to the official doc sample for the details.
It will have the step for container initialization as below, it pulls the container to the agent machine, the job tasks are executed on the container.
In addition, you are using name:XXX
for pool, which should be a self-hosted agent
, you need to make sure the agent machine is able to access the website xxx-sonarqube.azurewebsites
.
Please Check the network and DNS resolution in agent machine, so that the container could be able to access the website.
Edit:
As per the sonar cloud doc for CICD when host is behind proxy, you need to set parameters.
Try to add extraProperties
for the prepare task. Or you need to add the environment variables mentioned in doc which is equal.
- task: SonarCloudPrepare@3
displayName: 'Prepare analysis configuration'
inputs:
SonarCloud: 'SonarConn1'
...
extraProperties: |
# Additional properties that will be passed to the scanner,
# Put one key=value per line, example:
# sonar.exclusions=**/*.bin
sonar.scanner.proxyHost=proxyserver
sonar.scanner.proxyPort=port
sonar.scanner.proxyUser=username
sonar.scanner.proxyPassword=password
本文标签: Connect to Sonarqube from an Azure pipeline build within a containerStack Overflow
版权声明:本文标题:Connect to Sonarqube from an Azure pipeline build within a container - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741922749a2405103.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
container
should be aligned withpool
, and check the network setting on your agent machine, make sure the container can access the website, please check the details below, thanks. – wade zhou - MSFT Commented Feb 10 at 2:03extraProperties
for the prepare task, I will add detail below. – wade zhou - MSFT Commented Feb 12 at 2:34