由网友(无人转角)分享简介:我正在尝试在Jenkins中配置新管道。我已经在Windows Server上购买并安装了jFrog artiFactory PRO,它已启动并在以下位置运行:https://artifactory.mycompany.com我在这里找到了这个示例:https://github.com/jfrog/project-e...![把JFrog Artifactory作为Docker镜像仓库](https://p.xsw88.cn/allimgs/daicuo/20230903/2532.png)
我正在尝试在Jenkins中配置新管道。我已经在Windows Server上购买并安装了jFrog artiFactory PRO,它已启动并在以下位置运行:https://artifactory.mycompany.com
我在这里找到了这个示例: https://github.com/jfrog/project-examples/blob/master/jenkins-examples/pipeline-examples/declarative-examples/docker-push-example/Jenkinsfile
![把JFrog Artifactory作为Docker镜像仓库](https://p.xsw88.cn/allimgs/daicuo/20230903/2532.png)
更具体地说这一节:
stage ('Push image to Artifactory') {
steps {
rtDockerPush(
serverId: "ARTIFACTORY_SERVER",
image: ARTIFACTORY_DOCKER_REGISTRY + '/hello-world:latest',
// Host:
// On OSX: "tcp://127.0.0.1:1234"
// On Linux can be omitted or null
host: HOST_NAME,
targetRepo: 'docker-local',
// Attach custom properties to the published artifacts:
properties: 'project-name=docker1;status=stable'
)
}
}
它正在构建和创建docker图像,但当它推送图像时,它无法推送图像并出错。不确定以下内容中应包含的内容:
ARTIFACTORY_DOKER_REGISTRY 主机:HOST_NAME我已经在artiFactory"docker-local"中创建了一个新的本地存储库。已尝试省略主机并获取
"不支持的操作系统"。
将host放回"host:‘tcp://IP Addresss"或"artifactory.mypanany.com:80/artiFactory"将生成
"不支持的协议方案"
如何配置Jenkins管道以使用jFrog artiFactory?
推荐答案
找到解决方案:
ARTIFACTORY_DOKER_REGISTRY应为IP/ArtiFactory-Repo-Key/Image:Tag主机应为docker守护程序(docker for windows为本地主机:2375)
stage('Build image') { // build and tag docker image
steps {
echo 'Starting to build docker image'
script {
def dockerfile = 'Dockerfile'
def customImage = docker.build('10.20.111.23:8081/docker-virtual/hello-world:latest', "-f ${dockerfile} .")
}
}
}
stage ('Push image to Artifactory') { // take that image and push to artifactory
steps {
rtDockerPush(
serverId: "jFrog-ar1",
image: "10.20.111.23:8081/docker-virtual/hello-world:latest",
host: 'tcp://localhost:2375',
targetRepo: 'local-repo', // where to copy to (from docker-virtual)
// Attach custom properties to the published artifacts:
properties: 'project-name=docker1;status=stable'
)
}
}
相关推荐
最新文章