-
Notifications
You must be signed in to change notification settings - Fork 1
/
secretFile-declarative.Jenkinsfile
40 lines (40 loc) · 1.11 KB
/
secretFile-declarative.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
pipeline {
agent {
kubernetes {
defaultContainer 'kaniko'
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
"""
}
}
environment {
IMAGE_PUSH_DESTINATION="kyounger/kaniko-jenkins:jenkins-secret-declarative"
}
stages {
stage('Build with Kaniko') {
steps {
checkout scm
container(name: 'kaniko', shell: '/busybox/sh') {
withCredentials([file(credentialsId: 'docker-credentials', variable: 'DOCKER_CONFIG_JSON')]) {
withEnv(['PATH+EXTRA=/busybox']) {
sh '''#!/busybox/sh
cp $DOCKER_CONFIG_JSON /kaniko/.docker/config.json
/kaniko/executor --context `pwd` --destination $IMAGE_PUSH_DESTINATION
'''
}
}
}
}
}
}
}