forked from kunchalavikram1427/kaniko-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
70 lines (70 loc) · 1.65 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
pipeline {
agent {
kubernetes {
yaml '''
apiVersion: v1
kind: Pod
metadata:
labels:
app: test
spec:
containers:
- name: git
image: bitnami/git:latest
command:
- cat
tty: true
- name: maven
image: maven:3.8.3-adoptopenjdk-11
command:
- cat
tty: true
- name: kaniko
image: gcr.io/kaniko-project/executor:debug
command:
- cat
tty: true
volumeMounts:
- name: kaniko-secret
mountPath: /kaniko/.docker
volumes:
- name: kaniko-secret
secret:
secretName: regcred
items:
- key: .dockerconfigjson
path: config.json
'''
}
}
environment{
DOCKERHUB_USERNAME = "kunchalavikram"
APP_NAME = "kaniko-webapp-demo"
IMAGE_NAME = "${DOCKERHUB_USERNAME}" + "/" + "${APP_NAME}"
IMAGE_TAG = "${BUILD_NUMBER}"
}
stages {
stage('Checkout SCM') {
steps {
container('git') {
git url: 'https://github.com/kunchalavikram1427/maven-employee-web-application.git',
branch: 'master'
}
}
}
stage('Build SW'){
steps {
container('maven'){
sh 'mvn -Dmaven.test.failure.ignore=true clean package'
}
}
}
stage('Build Container Image'){
steps {
container('kaniko'){
sh "/kaniko/executor --context $WORKSPACE --destination $IMAGE_NAME:$IMAGE_TAG"
}
}
}
}
}