docker push to artifactory gives error : "Target host is not specified "

I am trying to push docker image to artifactory using jenkins declarative pipeline. Below is my code :

 stage('Push Image to Artifactory') {
            steps {
                script{
                    def buildInfo = Artifactory.newBuildInfo()
                    def server = Artifactory.newServer url: 'artifactory.org', credentialsId: 'artifactsId'
             
                        def rtDocker = Artifactory.docker server: server
                        def tagDockerApp = "artifactory.org/docker-repository/venus:1.0.3"

                        docker.build(tagDockerApp)
                        buildInfo = rtDocker.push(tagDockerApp,'docker-local-repository',buildInfo)
                       
                    // Publish build info.

                        buildInfo.env.capture = true
                        buildInfo.env.collect()
                        server.publishBuildInfo buildInfo
                }
            }
        }

I am getting below error after rtDocker.push command :

org.apache.http.ProtocolException: Target host is not specified
    at org.apache.http.impl.conn.DefaultRoutePlanner.determineRoute(DefaultRoutePlanner.java:71)
    at org.apache.http.impl.client.InternalHttpClient.determineRoute(InternalHttpClient.java:125)
    at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
Caused: org.apache.http.client.ClientProtocolException
    at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:187)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
    at org.jfrog.build.client.PreemptiveHttpClient.execute(PreemptiveHttpClient.java:102)
    at org.jfrog.build.extractor.clientConfiguration.client.ArtifactoryDependenciesClient.execute(ArtifactoryDependenciesClient.java:200)
    at org.jfrog.build.extractor.clientConfiguration.client.ArtifactoryDependenciesClient.downloadArtifact(ArtifactoryDependenciesClient.java:170)
    at org.jfrog.hudson.pipeline.docker.DockerImage.findAndSetManifestFromArtifactory(DockerImage.java:162)
    at org.jfrog.hudson.pipeline.docker.DockerImage.generateBuildInfoModule(DockerImage.java:146)
    at org.jfrog.hudson.pipeline.steps.DockerPushStep$Execution.run(DockerPushStep.java:135)
    at org.jfrog.hudson.pipeline.steps.DockerPushStep$Execution.run(DockerPushStep.java:86)
    at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:47)
    at hudson.security.ACL.impersonate(ACL.java:367)
    at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

Although i can see the image pushed on to the artifactory , but due to the exception i am not able publish build info and execute other stages

Source: Docker Questions

LEAVE A COMMENT