def label = "mypod-${UUID.randomUUID().toString()}"
podTemplate(label: label, yaml: """
kind: Pod
metadata:
name: kaniko
spec:
containers:
- name: kaniko
image: gcr.io/kaniko-project/executor:debug
imagePullPolicy: Always
command:
- /busybox/cat
tty: true
volumeMounts:
- name: jenkins-docker-cfg
mountPath: /root
volumes:
- name: jenkins-docker-cfg
projected:
sources:
- secret:
name: regcred
items:
- key: .dockerconfigjson
path: .docker/config.json
"""
) {
node(label) {
stage('Build with Kaniko') {
sh label: '', script: 'free -m'
timeout(time: 2, unit: 'HOURS'){
dir('ab7files') {
checkout scm: [$class: 'GitSCM', userRemoteConfigs: [[url: 'xxxxxx.git', credentialsId: 'xxxxxxx']], branches: [[name: 'refs/tags/v1.0.0']]],poll: false
}
}
timeout(time: 2, unit: 'HOURS'){
dir('hybrisfiles') {
git branch: 'master', credentialsId: 'xxxxxx', url: 'xxxxxx.git'
}
}
timeout(time: 2, unit: 'HOURS'){
dir('tools') {
git branch: 'master', credentialsId: 'xxxxxx', url: 'xxxxxxxx.git'
}
}
timeout(time: 2, unit: 'HOURS'){
dir('dockersource') {
git branch: 'master', credentialsId: 'xxxxxxxxxxx', url: 'xxxxxxxxxxxx.git'
}
}
container(name: 'kaniko', shell: '/busybox/sh') {
withEnv(['PATH+EXTRA=/busybox:/kaniko']) {
sh '''#!/busybox/sh
/kaniko/executor -f /home/jenkins/workspace/buildhybris/dockersource/hybris/Dockerfile -c `pwd` --destination=xxxx/xxxx:test0.1
'''
}
}
}
}
}
kubectl create secret docker-registry regcred --docker-server=https://index.docker.io/v1/ --docker-username=baibaibaibai --docker-password=7575757575 --docker-email=marshal_li_b@163.com -n autotest