forked from ericHumberto/springboot-test-CI
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile
53 lines (53 loc) · 1.47 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
pipeline {
agent any
triggers {
pollSCM '* * * * *'
}
stages {
stage('Build') {
steps {
sh './gradlew assemble'
}
}
stage('Test') {
steps {
sh './gradlew test'
}
}
stage('Build Docker Image') {
steps {
sh './gradlew docker'
}
}
stage('SCA') {
steps {
sh 'trivy image andersoncmciet/springboot-test-ci:0.0.1-SNAPSHOT'
}
}
stage('Push Docker Image') {
environment {
DOCKER_HUB_LOGIN = credentials('dockerhub')
}
steps {
sh 'docker login --username=$DOCKER_HUB_LOGIN_USR --password=$DOCKER_HUB_LOGIN_PSW'
sh './gradlew dockerPush'
}
}
stage('Promote') {
environment {
OKTETO_NAMESPACE = credentials('okteto-namespace')
OKTETO_SECRET = credentials('okteto-secret')
}
steps {
sh '''
okteto login --token $OKTETO_SECRET
okteto namespace $OKTETO_NAMESPACE
okteto kubeconfig
kubectl apply -f k8s.yml
kubectl rollout restart deployment.apps/springboot-test-ci
kubectl rollout status deployment.apps/springboot-test-ci
'''
}
}
}
}