2

我正在尝试使用 jenkins 声明性管道将 docker 图像推送到工件。下面是我的代码-

 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-repository',buildInfo)
                       
                    // Publish build info.

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

rtDocker.push 命令后出现以下错误:

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)

虽然我可以看到推送到工件上的图像,但由于异常我无法发布构建信息并执行其他阶段

4

1 回答 1

1

尝试提供包含协议 (http/https) 的完整 url,例如https://artifactory.org

def server = Artifactory.newServer url: 'artifactory.org', credentialsId: 'artifactsId'

于 2021-01-12T15:48:21.333 回答