-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
42 lines (37 loc) · 1.22 KB
/
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
42
@Library('global-libs') _
pipeline {
agent {
kubernetes {
containerTemplate(name: 'kaniko', image: 'gcr.io/kaniko-project/executor:debug', command: 'sleep', args: '99d')
}
}
stages {
stage('Login credentials') {
steps {
script {
//gitlab_docker.login()
withCredentials([usernamePassword(credentialsId: 'gitlab-registry', usernameVariable: 'USERNAME', passwordVariable: 'TOKEN')]) {
sh '''
echo "{\"auths\":{\"registry.gitlab.com\":{\"username\":\"$USERNAME\",\"password\":\"$TOKEN\"}}}" > /kaniko/.docker/config.json
'''
}
}
}
}
stage('Build & Push') {
steps {
script {
sh '''
/kaniko/executor --context app/ \
--dockerfile Dockerfile \
--cache \
--build-arg CI_COMMIT_REF_SLUG=${GIT_BRANCH} \
--build-arg CI_COMMIT_TAG=${GIT_TAG} \
--build-arg CI_COMMIT_SHORT_SHA=${GIT_COMMIT} \
--destination registry.gitlab.com/dev-ops-tom/test \
'''
}
}
}
}
}