forked from CMYanko/spring-petclinic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
executable file
·129 lines (121 loc) · 4.37 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
pipeline {
agent any
stages {
stage('Build') {
steps {
sh '''
echo "PATH = ${PATH}"
echo "M2_HOME = ${M2_HOME}"
mvn help:evaluate -Dexpression=settings.localRepository
mvn versions:set -DnewVersion=2.0.0
mvn package -B -DskipTests=true
'''
}
}
stage ('Creating build tag') {
steps {
createTag nexusInstanceId: 'nx3', tagAttributesJson: '{"createdBy" : "Moose"}', tagName: 'build-123'
createTag nexusInstanceId: 'nx3', tagAttributesJson: '{"createdBy" : "Moose"}', tagName: 'build-125'
}
}
stage ('Publishing') {
parallel {
stage ('Publish to Build Tag 125') {
steps {
nexusPublisher nexusInstanceId: 'nx3', nexusRepositoryId: 'maven-releases', packages: [[$class: 'MavenPackage', mavenAssetList: [[classifier: '', extension: '', filePath: 'target/spring-petclinic-2.0.0.jar']], mavenCoordinate: [artifactId: 'fancyWidget', groupId: 'com.mycompany', packaging: 'jar', version: '2.0.0']]], tagName: 'build-125'
}
}
stage ('Publish to Build Tag 123') {
steps {
nexusPublisher nexusInstanceId: 'nx3', nexusRepositoryId: 'maven-releases', packages: [[$class: 'MavenPackage', mavenAssetList: [[classifier: '', extension: '', filePath: 'target/spring-petclinic-2.0.0.jar']], mavenCoordinate: [artifactId: 'fancyWidget', groupId: 'com.mycompany', packaging: 'jar', version: '1.0.0']]], tagName: 'build-123'
}
}
stage ('Publish to Build Tag 120') {
steps {
nexusPublisher nexusInstanceId: 'nx3', nexusRepositoryId: 'maven-releases', packages: [[$class: 'MavenPackage', mavenAssetList: [[classifier: '', extension: '', filePath: 'target/spring-petclinic-2.0.0.jar']], mavenCoordinate: [artifactId: 'fancyWidget', groupId: 'com.mycompany', packaging: 'jar', version: '0.0.1']]], tagName: 'build-120'
}
}
}
}
stage ('Next Steps') {
steps {
input "Deploy to Prod?"
moveComponents destination: 'maven-test', nexusInstanceId: 'nx3', tagName: 'build-123'
}
}
stage ('Delete') {
steps {
deleteComponents nexusInstanceId: 'nx3', tagName: 'build-120'
}
}
stage('Scan App - Build Container') {
parallel {
stage('IQ-BOM') {
steps {
nexusPolicyEvaluation(iqApplication: 'petclinic', iqStage: 'build', iqScanPatterns: [[scanPattern: '']])
}
}
stage('Static Analysis') {
steps {
echo '...run SonarQube or other SAST tools here'
}
}
stage('Build Container') {
steps {
sh '''
docker build -t test-boot .
'''
}
}
}
}
stage('Test Container') {
steps {
echo '...run container and test it'
}
post {
success {
echo '...the Test Scan Passed!'
}
failure {
echo '...the Test FAILED'
error '...the Container Test FAILED'
}
}
}
stage('Scan Container') {
steps {
echo '...TODO scan container'
}
post {
success {
echo '...the IQ Scan PASSED'
postGitHub(commitId, 'success', 'analysis', 'Nexus Lifecycle Container Analysis succeeded', "${policyEvaluationResult.applicationCompositionReportUrl}")
}
failure {
echo '...the IQ Scan FAILED'
postGitHub(commitId, 'failure', 'analysis', 'Nexus Lifecycle Containe Analysis failed', "${policyEvaluationResult.applicationCompositionReportUrl}")
error '...the IQ Scan FAILED'
}
}
}
stage('Clean Up Validation') {
steps {
input "Clean Up??"
}
}
stage('Delete all the things') {
steps {
deleteComponents nexusInstanceId: 'nx3', tagName: 'build-125'
deleteComponents nexusInstanceId: 'nx3', tagName: 'build-123'
sh '''
curl --verbose -u admin:admin123 -X DELETE "http://nexus:8081/service/rest/v1/tags/build-125" -H "accept: application/json"
curl --verbose -u admin:admin123 -X DELETE "http://nexus:8081/service/rest/v1/tags/build-123" -H "accept: application/json"
'''
}
}
}
tools {
maven 'maven360'
}
}