forked from gencat/demo-JEE-REST
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
167 lines (145 loc) · 5.7 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#!usr/bin/groovy
@Library('github.com/mostrovoi/pipeline-library@master') _
demoCanigoTemplate(label: 'maven-and-docker-and-kubectl') {
node('maven-and-docker-and-kubectl') {
container(name: 'maven') {
stage("Checkout") {
checkout scm
}
stage("Build") {
sh "mvn clean package -Dmaven.test.failure.ignore"
//TODO: Change to publish html
junit healthScaleFactor: 1.0, testResults: 'target/surefire-reports/TEST*.xml'
}
stage ('Anàlisi de codi estàtic') {
withSonarQubeEnv("SonarQubeServer") {
sh "mvn sonar:sonar -Dsonar.host.url=$SONAR_HOST_URL"
}
}
//TODO: Moure fora del node, no cal un executor assignat
stage("Validació de SonarQube Gatekeeper") {
timeout(time: 5, unit: 'MINUTES') {
def qG = waitForQualityGate()
if(qG.status == 'OK')
echo "SONAR: Codi acompleix els mínims de qualitat. Enhorabona!"
else
error "SONAR: Codi no acompleix els mínims de qualitat : ${qG.status}"
}
}
stage("CESICAT: Anàlisi seguretat dependency check") {
try {
sh "mvn verify -Powasp-dependencycheck,dev"
}
finally {
publishHTML(target: [
reportDir : 'target',
reportFiles : 'dependency-check-report.html',
reportName : 'OWASP Dependency Check Informe',
keepAll : true,
alwaysLinkToLastBuild: true,
allowMissing : false
])
}
}
}
container(name: 'docker') {
stage ('Generació imatge docker') {
sh("docker build -t gencat.azurecr.io/demo-canigo:latest -f src/assembly/docker/app/Dockerfile .")
}
stage ('Pujar imatge docker al nostre registre') {
withCredentials([usernamePassword(credentialsId: 'azureRegistryId', passwordVariable: 'REGISTRY_PASSWORD', usernameVariable: 'REGISTRY_USERNAME')]) {
sh("docker login -u ${REGISTRY_USERNAME} -p ${REGISTRY_PASSWORD} gencat.azurecr.io")
sh("docker push gencat.azurecr.io/demo-canigo:latest")
}
}
}
//TODO: Externalitzar valors
container(name: 'clients') {
stage ('Desplegament INT') {
deployProject{
stagedProject = 'demo-canigo:latest'
resourceLocation = 'src/assembly/kubernetes/kubernetes-dev.yaml'
environment = 'dev'
registry = 'gencat.azurecr.io'
}
}
}
container(name: 'maven') {
//TODO: Not sure of the real nature of smoke tests
stage ('Smoke Test INT') {
sh "mvn verify -Dmaven.test.failure.ignore -PsmokeTest,int -Dserver.url=http://bookstore.dev.matxa.es"
//TODO: Machaca los surefire-reports
junit healthScaleFactor: 1.0, testResults: 'target/failsafe-reports/TEST*.xml'
}
stage('Acceptance Test INT') {
sh "mvn verify -Dmaven.test.failure.ignore -PintegrationTest,int -Dserver.url=http://bookstore.dev.matxa.es"
}
stage ('CESICAT: Anàlisi seguretat amb ZAP') {
try {
sh "mvn -Powasp-zap,dev verify"
}
finally {
//archiveArtifacts artifacts: '*/target/zap-reports/*.xml'
publishHTML(target: [
reportDir : 'target/zap-reports',
reportFiles : 'zapReport.html',
reportName : 'ZAP Report',
keepAll : true,
alwaysLinkToLastBuild: true,
allowMissing : false
])
}
}
}
container(name: 'clients') {
stage ('Desplegament PRE') {
deployProject{
stagedProject = 'demo-canigo:latest'
resourceLocation = 'src/assembly/kubernetes/kubernetes-pre.yaml'
environment = 'pre'
registry = 'gencat.azurecr.io'
}
}
}
container(name: 'maven') {
stage ('Smoke Test PRE') {
sh "mvn verify -PsmokeTest,pre -Dserver.url=http://bookstore.pre.matxa.es"
}
stage ('Acceptance Test PRE') {
sh "mvn verify -PintegrationTest,pre -Dserver.url=http://bookstore.pre.matxa.es"
}
}
container(name: 'performance') {
stage('Capacity TEST PRE') {
sh "bzt src/test/jmeter/simple-assert.yml -o settings.artifacts-dir=artifacts"
}
}
stage ('Exploratory Test PRE') {
echo "Exploratory Test PRE"
input 'Vols promocionar el build a pro?'
}
container(name: 'clients') {
stage ('Desplegament PRO') {
deployProject{
stagedProject = 'demo-canigo:latest'
resourceLocation = 'src/assembly/kubernetes/kubernetes.yaml'
environment = 'pro'
registry = 'gencat.azurecr.io'
}
}
}
container(name: 'maven') {
stage ('Generació Tag DEFINITIU') {
echo "Generació Tag DEFINITIU"
//No cal contemplar-ho, ja ho ha fet l'Arnau
//Molt similar a generació tag intermig
}
stage ('Smoke Test PRO') {
sh "mvn verify -PsmokeTest,pre -Dserver.url=http://bookstore.matxa.es"
}
}
stage("Arxivar artefactes") {
archiveArtifacts artifacts: 'target/**/*'
}
}
}