连接到Gitlab连接到Sonar时的连接拒绝
我在配置Sonarqube配置GitLab管道时面临问题。 在localhot上运行的GitLab
端口80
和声纳在localhost
port 9000 在同一本地Linux机器中。
如果我正在从本地Linux终端执行命令与Sonar连接,则可以正常工作,但是在Gitlab管道中抛出错误的东西。
命令从终端和管道执行:
dotnet sonarscanner begin /k:“ project” /d:sonar.login = username /d:sonar.password = password = password = password = password /d:sonar.host.url = http://127.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0 .0.1:9000
执行上述命令后,其工作正常,但在Gitlab管道中会遇到Bellow错误。
无法请求并解析'http://127.0.0.1:1:9000/api/server/version':连接拒绝
stages:
- sonar
Gitlab Pipeline:
sonarqube-check:
stage: sonar
image: mcr.microsoft.com/dotnet/sdk:6.0
variables:
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar"
task cache
GIT_DEPTH: "0"
cache:
key: "${CI_JOB_NAME}"
paths:
- .sonar/cache
script:
- "apt-get update"
- "apt-get install --yes openjdk-11-jre"
- "dotnet tool install --global dotnet-sonarscanner"
- "export PATH=\"$PATH:$HOME/.dotnet/tools\""
- "dotnet sonarscanner begin /k:"trukkerfinops" /d:sonar.login=username /d:sonar.password=password /d:sonar.host.url=http://127.0.0.1:9000"
- "dotnet build"
- "dotnet sonarscanner end /d:sonar.login=\"$SONAR_TOKEN\""
allow_failure: true
only:
- main
(
[[runners]]
name = "devops"
url = "http://localhost/"
token = "token"
executor = "docker"
clone_url = "http://machine_ip"
[runners.custom_build_dir]
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]
[runners.cache.azure]
[runners.docker]
tls_verify = false
image = "dind"
privileged = true
disable_entrypoint_overwrite = false
oom_kill_disable = false
disable_cache = false
volumes = ["/var/run/docker.sock:/var/run/docker.sock", "/cache"]
shm_size = 0
127.0.0.1:9000
$ dotnet sonarscanner begin /k:"project" /d:sonar.login=username /d:sonar.password=password /d:sonar.host.url=http://localhost:9000
SonarScanner for MSBuild 5.6
Using the .NET Core version of the Scanner for MSBuild
Pre-processing started.
Preparing working directories...
13:52:04.682 Updating build integration targets...
13:52:04.781 Failed to request and parse 'http://localhost:9000/api/server/version': Cannot assign requested address (localhost:9000)
Unhandled exception. System.Net.Http.HttpRequestException: Cannot assign requested address (localhost:9000)
---> System.Net.Sockets.SocketException (99): Cannot assign requested address
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)
at System.Net.Sockets.Socket.<ConnectAsync>g__WaitForConnectWithCancellation|277_0(AwaitableSocketAsyncEventArgs saea, ValueTask connectTask, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.ConnectToTcpHostAsync(String host, Int32 port, HttpRequestMessage initialRequest, Boolean async, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
) Google的选项,但直到还没有运气
I am facing issue while configuring Gitlab pipeline with SonarQube.
Gitlab running on localhot
port 80
and Sonar running on localhost
port 9000
in the same local linux machine.
If I am executing command from local linux terminal to connect with Sonar, it works fine, but same thing throwing error in Gitlab pipeline.
Command to execute from Terminal and pipeline:
dotnet sonarscanner begin /k:"project" /d:sonar.login=username /d:sonar.password=password /d:sonar.host.url=http://127.0.0.1:9000
After executing above command it work fine but in Gitlab pipeline getting bellow error.
Failed to request and parse 'http://127.0.0.1:9000/api/server/version': Connection refused (127.0.0.1:9000)
stages:
- sonar
Gitlab Pipeline:
sonarqube-check:
stage: sonar
image: mcr.microsoft.com/dotnet/sdk:6.0
variables:
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar"
task cache
GIT_DEPTH: "0"
cache:
key: "${CI_JOB_NAME}"
paths:
- .sonar/cache
script:
- "apt-get update"
- "apt-get install --yes openjdk-11-jre"
- "dotnet tool install --global dotnet-sonarscanner"
- "export PATH=\"$PATH:$HOME/.dotnet/tools\""
- "dotnet sonarscanner begin /k:"trukkerfinops" /d:sonar.login=username /d:sonar.password=password /d:sonar.host.url=http://127.0.0.1:9000"
- "dotnet build"
- "dotnet sonarscanner end /d:sonar.login=\"$SONAR_TOKEN\""
allow_failure: true
only:
- main
Runner configuration:
[[runners]]
name = "devops"
url = "http://localhost/"
token = "token"
executor = "docker"
clone_url = "http://machine_ip"
[runners.custom_build_dir]
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]
[runners.cache.azure]
[runners.docker]
tls_verify = false
image = "dind"
privileged = true
disable_entrypoint_overwrite = false
oom_kill_disable = false
disable_cache = false
volumes = ["/var/run/docker.sock:/var/run/docker.sock", "/cache"]
shm_size = 0
Console log:
$ dotnet sonarscanner begin /k:"project" /d:sonar.login=username /d:sonar.password=password /d:sonar.host.url=http://localhost:9000
SonarScanner for MSBuild 5.6
Using the .NET Core version of the Scanner for MSBuild
Pre-processing started.
Preparing working directories...
13:52:04.682 Updating build integration targets...
13:52:04.781 Failed to request and parse 'http://localhost:9000/api/server/version': Cannot assign requested address (localhost:9000)
Unhandled exception. System.Net.Http.HttpRequestException: Cannot assign requested address (localhost:9000)
---> System.Net.Sockets.SocketException (99): Cannot assign requested address
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)
at System.Net.Sockets.Socket.<ConnectAsync>g__WaitForConnectWithCancellation|277_0(AwaitableSocketAsyncEventArgs saea, ValueTask connectTask, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.ConnectToTcpHostAsync(String host, Int32 port, HttpRequestMessage initialRequest, Boolean async, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
I have tried many more options from google but no luck till yet
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要提出HTTP请求
To make HTTP request please add
--net=host
to your code