forked from wcaquinocursos/tasks-backend
-
Notifications
You must be signed in to change notification settings - Fork 92
/
Jenkinsfile
91 lines (89 loc) · 3.34 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
pipeline {
agent any
stages {
stage ('Build Backend') {
steps {
bat 'mvn clean package -DskipTests=true'
}
}
stage ('Unit Tests') {
steps {
bat 'mvn test'
}
}
stage ('Sonar Analysis') {
environment {
scannerHome = tool 'SONAR_SCANNER'
}
steps {
withSonarQubeEnv('SONAR_LOCAL') {
bat "${scannerHome}/bin/sonar-scanner -e -Dsonar.projectKey=DeployBack -Dsonar.host.url=http://localhost:9000 -Dsonar.login=cf6826d57f1e453e08ecbd6cf862496472061f66 -Dsonar.java.binaries=target -Dsonar.coverage.exclusions=**/.mvn/**,**/src/test/**,**/model/**,**Application.java"
}
}
}
stage ('Quality Gate') {
steps {
sleep(5)
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 credentialsId: 'github_login', url: 'https://github.com/wcaquino/tasks-api-test'
bat 'mvn test'
}
}
}
stage ('Deploy Frontend') {
steps {
dir('frontend') {
git credentialsId: 'github_login', url: 'https://github.com/wcaquino/tasks-frontend'
bat '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 credentialsId: 'github_login', url: 'https://github.com/wcaquino/tasks-functional-tests'
bat 'mvn test'
}
}
}
stage('Deploy Prod') {
steps {
bat 'docker-compose build'
bat 'docker-compose up -d'
}
}
stage ('Health Check') {
steps {
sleep(5)
dir('functional-test') {
bat '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', onlyIfSuccessful: true
}
unsuccessful {
emailext attachLog: true, body: 'See the attached log below', subject: 'Build $BUILD_NUMBER has failed', to: '[email protected]'
}
fixed {
emailext attachLog: true, body: 'See the attached log below', subject: 'Build is fine!!!', to: '[email protected]'
}
}
}