简体   繁体   中英

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. For doing this I am providing Jenkins with the Nexus credentials and the path to find the repository. 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 .

Below is the code used in pipeline_config.yml file.

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

ex

docker exec -it s4sdk-jenkins-master bash

Then execute curl command to reach the nexus from there.

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.

this looks very much like an issue with the localhost URL. From within the Jenkins container, localhost refers to that container, and not to your local Nexus.

The solution should be to use the hostname of the Nexus in your pipeline config. 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:

  1. Change localhost: 8081 to address ip host, eg 192.168.0.3:8081

I fixed problem in my environment local.

I hope can helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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