forked from wcaquinocursos/tasks-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
105 lines (92 loc) · 3.33 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
pipeline {
tools {
maven "MAVEN_LOCAL"
}
agent any
stages {
stage ('Build Backend'){
steps{
sh 'mvn clean package -DskipTests=true'
}
}
stage ('Unit Tests'){
steps{
sh 'mvn test'
}
}
stage ('Sonar Analysis'){
environment {
scannerHome = tool 'SONAR_SCANNER'
}
steps{
withSonarQubeEnv('SONAR_LOCAL'){
sh "${scannerHome}/bin/sonar-scanner -e -Dsonar.projectKey=DeployBack -Dsonar.host.url=http://127.0.0.1:9000 -Dsonar.login=76302f81ca49ee7dff236e14537e1dd48fcaaa05 -Dsonar.java.binaries=target -Dsonar.coverage.exclusions=**/mvn**,**/src/test**,**/model/**,**/Application.java"
}
}
}
stage ('Quality Gate'){
steps{
sleep(30)
timeout(time: 1, unit:'MINUTES') {
waitForQualityGate abortPipeline: true
}
}
}
stage ('Deploy Backend'){
steps{
deploy adapters: [tomcat8(credentialsId: 'TomcatLogin', path: '', url: 'http://localhost:8001/')], contextPath: 'tasks-backend', war: 'target/tasks-backend.war'
}
}
stage ('API Test'){
steps{
dir('api-test') {
git 'https://github.com/zimablu3/tasks-api-test'
sh 'mvn test'
}
}
}
stage ('Deploy Frontend') {
steps{
dir('frontend') {
git 'https://github.com/zimablu3/tasks-frontend'
sh 'mvn clean package'
deploy adapters: [tomcat8(credentialsId: 'TomcatLogin', path: '', url: 'http://localhost:8001/')], contextPath: 'tasks', war: 'target/tasks.war'
}
}
}
stage ('Functional Test'){
steps{
dir('functional-test') {
git 'https://github.com/zimablu3/tasks-functional-tests'
sh 'mvn test'
}
}
}
stage('Deploy Prod') {
steps {
sh 'docker-compose build'
sh 'docker-compose up -d'
}
}
stage ('Health Check'){
steps{
sleep(15)
dir('functional-test') {
sh 'mvn verify -Dskip.surefire.tests'
}
}
}
}
post {
always {
junit allowEmptyResults: true, testResults: 'target/surefire-reports/*.xml, api-test/target/surefire-reports/*.xml,functional-test/target/surefire-reports/*.xml, functional-test/target/failsafe-reports/*.xml'
archiveArtifacts artifacts: 'target/tasks-backend.war, frontend/target/tasks.war', followSymlinks: false, onlyIfSuccessful: true
}
unsuccessful {
emailext attachLog: true, body: 'See the attached log below', subject: 'Build $BUILD_NUMBER has failed', to: 'warenreaper@gmail.com'
}
fixed {
emailext attachLog: true, body: 'See the attached log below', subject: 'Build is fine!!!', to: 'warenreaper@gmail.com'
}
}
}