如何使用Gradle Jib和Artifactory插件将Docker镜像的信息引入Artifactory构建信息?

nx7onnlm  于 2023-10-19  发布在  Docker
关注(0)|答案(2)|浏览(130)

我想用Gradle和Jib插件创建一个Docker镜像,并将其带到Artifactory。Docker镜像应该包含在Artifactory构建信息中。
我可以使用Jib插件创建Docker镜像。但是我如何才能将Docker镜像的信息导入Artifactory Buildinfo中呢?
我的gradle构建文件的相关部分:

plugins {
    id 'java'
    id 'maven-publish'
    id "com.google.cloud.tools.jib" version "3.3.2"
    id 'com.jfrog.artifactory' version '5.1.6'
}

jib {
    from {
        image = "myRepo/$myBaseImage"       
    }
    to {
        image = "myRepo/myProject:${myTag}"
    }
}

artifactory {
    contextUrl = 'https://myRepo/artifactory/'
    publish {
        repository {
            repoKey = 'myRepo'
        }
        clientConfig.info.setBuildNumber(project.version)
        defaults {
            publications ('ALL_PUBLICATIONS')
            publishBuildInfo = true
            publishArtifacts = true
        }
    }
}
k2arahey

k2arahey1#

默认情况下,在运行gradle jib或实际gradle jibDockerBuild之后,您可以分别在build/jib-image.digestbuild/jib-image.id处找到image digestimage ID
参考:https://github.com/GoogleContainerTools/jib/tree/master/jib-gradle-plugin#outputpaths-closure

mwkjh3gx

mwkjh3gx2#

要创建Docker镜像并将其上传到Artifactory,您可以参考这里提供的指南:https://github.com/GoogleContainerTools/jib/tree/master/jib-gradle-plugin#using-jfrog-container-registry-jcr-or-jfrog-artifactory
目前,JIB的构建信息收集仅由Jenkins Artifactory插件支持。您可以查看Maven JIB example,它也适用于Gradle。

相关问题