我想用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
}
}
}
2条答案
按热度按时间k2arahey1#
默认情况下,在运行
gradle jib
或实际gradle jibDockerBuild
之后,您可以分别在build/jib-image.digest
和build/jib-image.id
处找到image digest
和image ID
。参考:https://github.com/GoogleContainerTools/jib/tree/master/jib-gradle-plugin#outputpaths-closure
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。