Jenkins docker-build-step插件无法将图像推送到Docker云

我正在尝试使用docker-build-step插件与Jenkins构build图像并将其推送到Docker云端。 使用Jenkins Password Manager插件为Docker Hub添encryption码。

我分两步做。 第一步使用Build/Create Image命令。 该命令构build图像并使用构buildID对其进行标记。

第二步将图像推送到docker集线器。 这里是控制台跟踪:

 [Docker] INFO: Build image id:5240329f9db6 [Docker] INFO: Pushing image parthmodi/docker_demo:test_push [Docker] INFO: PushResponseItem[stream=<null>,status=The push refers to a repository [docker.io/parthmodi/docker_demo],progressDetail=<null>,progress=<null>,id=<null>,from=<null>,time=<null>,errorDetail=<null>,error=<null>,aux=<null>] 

 [Docker] INFO: PushResponseItem[stream=<null>,status=<null>,progressDetail=<null>,progress=<null>,id=<null>,from=<null>,time=<null>,errorDetail=ResponseItem.ErrorDetail[code=<null>,message=denied: requested access to the resource is denied],error=denied: requested access to the resource is denied,aux=<null>] ERROR: Build step failed with exception com.github.dockerjava.api.exception.DockerClientException: Could not push image: denied: requested access to the resource is denied at com.github.dockerjava.core.command.PushImageResultCallback.awaitSuccess(PushImageResultCallback.java:49) at org.jenkinsci.plugins.dockerbuildstep.cmd.PushImageCommand.execute(PushImageCommand.java:81) at org.jenkinsci.plugins.dockerbuildstep.DockerBuilder.perform(DockerBuilder.java:74) at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20) at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:736) at hudson.model.Build$BuildExecution.build(Build.java:206) at hudson.model.Build$BuildExecution.doRun(Build.java:163) at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:496) at hudson.model.Run.execute(Run.java:1737) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at hudson.model.ResourceController.execute(ResourceController.java:97) at hudson.model.Executor.run(Executor.java:421) Build step 'Execute Docker command' marked build as failure Finished: FAILURE 

这里是完整的跟踪: https : //pastebin.com/tFy399D5

为什么我得到Could not push image: denied: requested access to the resource is denied将图像推送到Docker Registry的错误,我能做些什么来解决它?

尝试这个

 stage('build and publish'){ def dockerImage = docker.build('dockerImageName') docker.withRegistry(RegistryURL, CredentialID) { dockerImage.push('latest') } }