jenkinsfile docker.withRegistry 使用子域方法推送到artifactory

发布于 2025-01-19 11:14:34 字数 832 浏览 1 评论 0原文

I've configured our artifactory instance using the 存储库路径方法。我正在尝试将内置的詹金斯(Jenkins)内置的图像推向文物,但它似乎忽略了存储库本身。

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")
} 

             

詹金斯(Jenkins)中的输出看起来像这样

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

,它忽略了地址的码头 - 位置部分。有什么想法吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浪漫之都 2025-01-26 11:14:34

对于 Docker 和 Jenkins Pipeline 的 Docker 插件,存储库是镜像参数的一部分,而不是注册表的一部分。一般来说,这看起来像:

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

请注意,Jenkins Pipeline 的 Artifactory Docker 注册表文档有时会使用术语“存储库”,而实际上它的意思是“注册表”,这可能会造成混淆和误导。另请注意,某些图像没有参数的存储库部分,因为它们是官方的。

在您的情况下,代码将如下所示:

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

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')
} 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文