简体   繁体   English

无法将工件上传到 Nexus 存储库 - S4SDK 管道

[英]Unable to upload artifact to Nexus Repository - S4SDK Pipeline

I am trying to upload the artifact to Nexus repository using the Artifact deployment stage in the Jenkins pipeline.我正在尝试使用 Jenkins 管道中的工件部署阶段将工件上传到 Nexus 存储库。 For doing this I am providing Jenkins with the Nexus credentials and the path to find the repository.为此,我向 Jenkins 提供了 Nexus 凭据和查找存储库的路径。 But, this stage is failed with an error "the connection is refused to nexus".但是,此阶段因错误“连接被拒绝连接”而失败。

However, I am able to access Nexus on http://localhost:8081/nexus .但是,我可以在http://localhost:8081/nexus上访问 Nexus。

Below is the code used in pipeline_config.yml file.下面是在 pipeline_config.yml 文件中使用的代码。

artifactDeployment:
    nexus:
      version: nexus2
      url: 'http://localhost:8081/nexus/'
      repository: myrepo
      credentialsId: 'nexus'
      additionalClassifiers:
        - type: jar
          classifier: classes

截图

Could someone please suggest in resolving this issue?有人可以建议解决这个问题吗?

On your VM, login to your Jenkins container在您的 VM 上,登录到您的 Jenkins 容器

ex

docker exec -it s4sdk-jenkins-master bash

Then execute curl command to reach the nexus from there.然后执行 curl 命令从那里到达 nexus。

ex

curl http://<your VM's IP>:8081/nexus

You will be able to upload artifact to nexus, only if the host is reachable from within the Jenkins container.只有在 Jenkins 容器内可以访问主机时,您才能将工件上传到 nexus。

this looks very much like an issue with the localhost URL.这看起来很像localhost URL 的问题。 From within the Jenkins container, localhost refers to that container, and not to your local Nexus.在 Jenkins 容器中, localhost 指的是该容器,而不是您本地的 Nexus。

The solution should be to use the hostname of the Nexus in your pipeline config.解决方案应该是在管道配置中使用 Nexus 的主机名。 It looks like this is the hostname of your laptop in this case.在这种情况下,这看起来像是您的笔记本电脑的主机名。

Hope this helps.希望这会有所帮助。

Best regards, Florian最好的问候,弗洛里安

If You have Jenkins and Nexus container, So:如果您有 Jenkins 和 Nexus 容器,那么:

  1. Change localhost: 8081 to address ip host, eg 192.168.0.3:8081将 localhost:8081 更改为地址 ip 主机,例如 192.168.0.3:8081

I fixed problem in my environment local.我在本地环境中解决了问题。

I hope can helps!希望能帮到你!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM