-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathk8sSecret-scripted.Jenkinsfile
41 lines (40 loc) · 1.07 KB
/
k8sSecret-scripted.Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
def label = "kaniko-${UUID.randomUUID().toString()}"
podTemplate(name: 'kaniko', label: label, yaml: """
kind: Pod
metadata:
name: kaniko
spec:
containers:
- name: kaniko
image: gcr.io/kaniko-project/executor:debug-v0.19.0
imagePullPolicy: Always
command:
- /busybox/cat
tty: true
volumeMounts:
- name: jenkins-docker-cfg
mountPath: /kaniko/.docker
volumes:
- name: jenkins-docker-cfg
projected:
sources:
- secret:
name: docker-credentials
items:
- key: .dockerconfigjson
path: config.json
""") {
node(label) {
def IMAGE_PUSH_DESTINATION="kyounger/kaniko-jenkins:k8s-secret"
stage('Build with Kaniko') {
checkout scm
container(name: 'kaniko', shell: '/busybox/sh') {
withEnv(['PATH+EXTRA=/busybox',"IMAGE_PUSH_DESTINATION=${IMAGE_PUSH_DESTINATION}"]) {
sh '''#!/busybox/sh
/kaniko/executor --context `pwd` --destination $IMAGE_PUSH_DESTINATION
'''
}
}
}
}
}