Skip to main content

jenkins

配置

pod 模板配置

apiVersion: v1
data:
config.json: >-
ewo9CiXV0aCAgInJlZ2lzdHJ5Lm5nYWlvdC5jb20iOiB7CiAgICAgmxwMlRTMGtkaAgIH0KfICAiYXV0aCI6ICJZblZwYkdSbHMiOiBgICAiYk50UTJGRyIKICAgICB7CiAgIGNqcFNkbWg1VQ==
kind: Secret
metadata:
name: image-registry-auths-config
namespace: devops-tools
type: Opaque

{
"auths": {
"registry.xxxxx.com": {
"auth": "bGdmh5RlS0kdjcjpSVlp2TNtYnVpQ2FG"
}
}
}

pipeline

podTemplate {
# 使用哪个 pod 模板 label
node('pod-templ-jenkins-slave-common') {
stage('Run shell') {
# 下载代码
git url: 'https://gitea.ngaiot.com/free-sun-zhenjiang/node.git', branch: 'main', credentialsId: 'gitea-builder'
# 在哪个容器里执行命令
# 容器模板里的 container name
container('image-build') {
sh '''
# 这个实际使用时不用
# 看 是否配置仓库授权
cat /kaniko/.docker/config.json

# 构建镜像
# --dockerfile: Dockerfile 的路径
# --destination: 推送的 image
# 构建完成后会自动推送
/kaniko/executor --dockerfile=dev/12/Dockerfile --destination=registry.ngaiot.com/${DEVOPS}/node:12-fs-${IMAGE_VERSION}
'''
}
}
}
}


环境变量

DEVOPS
FS-CLOUD
IMAGE_VERSION
IOT
ZHIWUCLOUD

...
...

NPM 仓库 Maven 仓库