jenkins - 在 Jenkins Slave 中运行 Kaniko
问题描述
我想在 jenkins 中将 kaniko 作为奴隶运行。我的管道在 docker 插件上运行,我如何使用 kaniko 设置 gcr 凭据。
我想将 GCR 凭据上传到 Jenkins 主服务器。
我的管道 groovy 如下所示:
node("kaniko-jnlp") {
stage('Building Stage') {
git 'https://github.com/jenkinsci/docker-jnlp-slave.git'
sh ''' /kaniko/executor -f `pwd`/Dockerfile -c `pwd` --insecure-
skip-tls-verify --cache=true
--- destination=gcr.io/project/project:v1 '''
}
解决方案
I run my whole pipeline encapsulated inside a pod, here how I use Kaniko:
pipeline {
agent {
kubernetes {
yaml """
apiVersion: v1
kind: Pod
metadata:
labels:
jenkins: worker
spec:
containers:
- name: kaniko
image: gcr.io/kaniko-project/executor:debug
command: ["/busybox/cat"]
tty: true
volumeMounts:
- name: dockercred
mountPath: /root/.docker/
volumes:
- name: dockercred
secret:
secretName: dockercred
"""
}
}
stages {
stage('Stage 1: Build with Kaniko') {
steps {
container('kaniko') {
sh '/kaniko/executor --context=git://github.com/repository/project.git \
--destination=repository/image:tag \
--insecure \
--skip-tls-verify \
-v=debug'
}
}
}
}
}
推荐阅读
- javascript - React Native,redux 功能在更新后不会恢复到原始状态
- python - 如何找到 IPython 单元格的宽度?
- python - 关于使用 Python scipy 对信号进行反卷积的问题
- bash - 不确定如何正确使用变量并在 bash 脚本中的 if 语句中使用它们
- reactjs - 如何在 React 中显示来自全局状态的数据?
- api - API 认证令牌
- angular - 以角度 8 将德语区域设置数字格式 (0,01) 转换为英语区域设置格式 (0.01)
- python - 使用 opencv 加载使用 tifffile 保存的图像
- java - 在 Sax Parser JAVA 中创建层次结构
- typescript - Typescript - 我可以动态设置函数的返回类型吗?