Home > Software design >  jenkinsfile docker.withRegistry push to artifactory with the subdomain method
jenkinsfile docker.withRegistry push to artifactory with the subdomain method

Time:04-07

I've configured our artifactory instance using the repository path method. I'm trying to push an image built in Jenkins to Artifactory, but it seems to ignore the repository path itself.

def dockerImage = _dockerImage("kl_alpha")
docker.withRegistry( "https://artifactory-dev.foobar.com/docker-local", "someCreds") {
  // def dockerImage =  docker.build("kl_alpha:$BUILD_NUMBER", "./")
  dockerImage.push()
  dockerImage.push("latest")
} 

             

The output in Jenkins looks something like this

  docker push artifactory-dev.foobar.com/kl_alpha:25
The push refers to repository [artifactory-dev.foobar.com/kl_alpha]

As you can see, it's ignoring the docker-local part of the address. Any ideas?

CodePudding user response:

For Docker and the Docker plugin for Jenkins Pipeline, the repository is part of the image argument, and not the registry. In general this would appear like:

docker.withRegistry('<registry url>') {}
  def dockerImage = docker.build('<repository>/<image name>:<tag>')
}

Note that Artifactory Docker registry documentation for Jenkins Pipeline sometimes uses the term "repository" when it actually means "registry", and that can be confusing and misleading. Note also that some images do not have a repository part of the argument because they are official.

In your situation, the code would appear like:

docker.withRegistry('https://artifactory-dev.foobar.com', 'someCreds') {
  def dockerImage = docker.build("docker-local/kl_alpha:${BUILD_NUMBER}", './')
  dockerImage.push()
  dockerImage.push('latest')
} 
  • Related