我在跑步
Jenkins
在带有kubernetes管道插件的kubernetes集群之上。
我用了一个集装箱
podTemplate
以最新的形象
google/cloud-sdk
.
与
cloud-sdk
我将构建的docker映像推送到存储库。
管道的精简版本:
podTemplate(label: label,
containers: [
containerTemplate(name: 'gcloud', image: 'google/cloud-sdk:latest', command: 'cat', ttyEnabled: true),
],
volumes: [
hostPathVolume(mountPath: '/var/run/docker.sock', hostPath: '/var/run/docker.sock')
]) {
node(label) {
...
stage('Develop deployment') {
container('gcloud') {
withCredentials([file(credentialsId: 'google-service-account-key', variable: 'GOOGLE_APPLICATION_CREDENTIALS')]) {
sh """#!/bin/bash
set -e
# setup gcloud setting
...
docker build --build-arg IMAGE_PREFIX="$GCLOUD_REGION/$GCLOUD_PROJECT" --build-arg TAG=$2 -f $DOCKERFILE -t $1 .
# push image to gcloud
...
"""
}
}
}
}
}
Docker图像使用
ARG
要为基础图像添加前缀,请执行以下操作:
ARG IMAGE_PREFIX
ARG TAG
FROM ${IMAGE_PREFIX}/client:${TAG} as some-client
...
Docker生成失败
Please provide a source image with
从
prior to commit
.
我已经检查了Docker的版本
云SDK
图片和Docker用于Kubernetes节点,它们都是最新的,至少比引入此功能的版本更新
(Using
ARG
before
FROM
)
.
有什么问题吗?