-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathJenkinsfile
55 lines (47 loc) · 1.55 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
#! groovy
pipeline {
agent {
kubernetes {
defaultContainer 'java'
yamlFile 'jnlp.yaml'
}
}
environment {
GITHASH = GIT_COMMIT.take(7)
DOCKER_BACKEND_IMAGE = "729601114034.dkr.ecr.ap-northeast-1.amazonaws.com/insecurity-backend"
}
stages {
stage('Build Docker Image') {
steps {
container('kaniko-crane') {
sh '''
/kaniko/executor --dockerfile=`pwd`/docker/Dockerfile.backend --context `pwd` \
--no-push --destination=backend:latest --tarPath image.tar
'''
}
}
}
stage('Scan Docker Image') {
steps {
container('trivy') {
sh '''
trivy image --exit-code 0 --severity MEDIUM --no-progress --input image.tar
trivy image --exit-code 1 --severity HIGH,CRITICAL --no-progress --input image.tar
'''
}
}
}
stage('Push Docker Image') {
steps {
container('kaniko-crane') {
sh '''
mkdir -p ~/.docker
echo '{ "credsStore": "ecr-login" }' > ~/.docker/config.json
/kaniko/crane push image.tar ${DOCKER_BACKEND_IMAGE}:${GITHASH}.${BUILD_NUMBER}
/kaniko/crane push image.tar ${DOCKER_BACKEND_IMAGE}:latest_en
'''
}
}
}
}
}