-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathJenkinsfile
95 lines (92 loc) · 2.91 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
#!/usr/bin/env groovy
def dockerImage
def tagMatchRules = [
[
meTypes: [
[meType: 'SERVICE']
],
tags : [
[context: 'CONTEXTLESS', key: 'Frontend']
]
], [
meTypes: [
[meType: 'SERVICE']
],
tags : [
[context: 'CONTEXTLESS', key: 'Database']
]
]
]
pipeline {
agent {
label 'docker'
}
options {
ansiColor('xterm')
timestamps()
timeout(30)
disableConcurrentBuilds()
buildDiscarder logRotator(numToKeepStr: '25')
}
triggers {
cron '@daily'
}
stages {
stage('Maven Build') {
steps {
script {
docker.image('maven:3-jdk-8-slim').inside {
sh 'mvn clean package --batch-mode'
}
}
// publishCoverage adapters: [jacocoAdapter('target/jacoco.exec')]
// findbugs pattern: '**/target/findbugsXml.xml'
// checkstyle pattern: '**/target/checkstyle-result.xml'
// junit allowEmptyResults: true, testResults: '**/target/surefire-reports/**/*.xml'
archiveArtifacts artifacts: '**/target/*.jar,**/target/*.war', fingerprint: true
}
}
stage('Docker Build') {
steps {
script {
dockerImage = docker.build('spring-petclinic:latest')
}
}
}
stage('Deploy to Staging Server') {
steps {
createDynatraceDeploymentEvent(envId: 'Dynatrace Demo Environment', tagMatchRules: tagMatchRules) {
sh 'docker-compose down'
sh 'docker-compose up -d'
}
}
}
stage('Performance Test') {
steps {
recordDynatraceSession(envId: 'Dynatrace Demo Environment', testCase: 'loadtest', tagMatchRules: tagMatchRules) {
performanceTest(readFile('performanceTest.json'))
}
perfSigDynatraceReports envId: 'Dynatrace Demo Environment', specFile: 'specfile.json', nonFunctionalFailure: 2
}
}
stage('Docker Push') {
steps {
script {
docker.withRegistry('https://hub.docker.com', 'dockerHubCredentials') {
dockerImage.push('latest')
}
}
}
}
stage('deploy to Production') {
steps {
echo 'deploy to Production!'
}
}
}
post {
always {
step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: 'notify@me', sendToIndividuals: false])
}
}
}