forked from MaartenSmeets/spring-boot-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
65 lines (57 loc) · 1.83 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
pipeline {
agent any
tools {
jdk 'jdk-11'
maven 'mvn-3.6.3'
}
stages {
stage('Build') {
steps {
withMaven(maven : 'mvn-3.6.3') {
sh "mvn package"
}
}
}
stage ('OWASP Dependency-Check Vulnerabilities') {
steps {
withMaven(maven : 'mvn-3.6.3') {
sh 'mvn dependency-check:check'
}
dependencyCheckPublisher pattern: 'target/dependency-check-report.xml'
}
}
stage('SonarQube analysis') {
steps {
withSonarQubeEnv(credentialsId: 'sonarqube-secret', installationName: 'sonarqube-server') {
withMaven(maven : 'mvn-3.6.3') {
sh 'mvn sonar:sonar -Dsonar.dependencyCheck.jsonReportPath=target/dependency-check-report.json -Dsonar.dependencyCheck.xmlReportPath=target/dependency-check-report.xml -Dsonar.dependencyCheck.htmlReportPath=target/dependency-check-report.html'
}
}
}
}
stage('Create and push container') {
steps {
withCredentials([usernamePassword(credentialsId: 'docker-credentials', usernameVariable: 'DOCKER_USERNAME', passwordVariable: 'DOCKER_PASSWORD')]) {
withMaven(maven : 'mvn-3.6.3') {
sh "mvn jib:build"
}
}
}
}
stage('Anchore analyse') {
steps {
writeFile file: 'anchore_images', text: 'docker.io/maartensmeets/spring-boot-demo'
anchore name: 'anchore_images'
}
}
stage('Deploy to K8s') {
steps {
withKubeConfig([credentialsId: 'kubernetes-config']) {
sh 'curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl"'
sh 'chmod u+x ./kubectl'
sh './kubectl apply -f k8s.yaml'
}
}
}
}
}