-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
176 lines (175 loc) · 5.92 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
166
167
168
169
170
171
172
173
174
175
176
pipeline {
options { disableConcurrentBuilds() }
agent { label 'docker-slave' }
stages {
stage ('Pull repo code from github') {
steps {
checkout scm
}
}
stage ('Build refactoring-option-discoverer') {
when {
not {
triggeredBy 'UpstreamCause'
}
}
steps {
build 'refactoring-option-discoverer/master'
}
}
stage('Test perf-predictor-api') {
steps {
sh """ #!/bin/bash
cd perf-predictor-api
python3 -mvenv .venv
. .venv/bin/activate
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements.txt
python3 -m pytest --pyargs -s ./tests --junitxml="results.xml" --cov=mlalgo --cov-report xml tests/
cp *.xml $WORKSPACE
"""
junit 'results.xml'
}
}
stage('Test forecast-api') {
steps {
sh """ #!/bin/bash
cd forecast-api
python3 -mvenv .venv
. .venv/bin/activate
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements.txt
python3 -m pytest --pyargs -s ./tests --junitxml="results1.xml" --cov=regression,timeseries --cov-report xml:coverage1.xml tests/
cp *.xml $WORKSPACE
"""
junit 'results1.xml'
}
}
stage('Test made-api') {
steps {
sh """ #!/bin/bash
cd made-api
python3 -mvenv .venv
. .venv/bin/activate
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements.txt
python3 -m pytest --pyargs -s ./tests --junitxml="results2.xml" --cov=utils --cov-report xml:coverage2.xml tests/
cp *.xml $WORKSPACE
"""
junit 'results2.xml'
}
}
stage ('Build rule-based refactorer') {
steps {
sh """ #!/bin/bash
cd rule-based
mvn clean install
"""
}
}
stage('SonarQube analysis perf-predictor-api'){
environment {
scannerHome = tool 'SonarQubeScanner'
}
steps {
withSonarQubeEnv('SonarCloud') {
sh """ #!/bin/bash
cd "perf-predictor-api"
${scannerHome}/bin/sonar-scanner
"""
}
}
}
stage('SonarQube analysis forecast-api'){
environment {
scannerHome = tool 'SonarQubeScanner'
}
steps {
withSonarQubeEnv('SonarCloud') {
sh """ #!/bin/bash
cd "forecast-api"
${scannerHome}/bin/sonar-scanner
"""
}
}
}
stage('SonarQube analysis made-api'){
environment {
scannerHome = tool 'SonarQubeScanner'
}
steps {
withSonarQubeEnv('SonarCloud') {
sh """ #!/bin/bash
cd "made-api"
${scannerHome}/bin/sonar-scanner
"""
}
}
}
stage('SonarQube analysis'){
environment {
scannerHome = tool 'SonarQubeScanner'
}
steps {
withSonarQubeEnv('SonarCloud') {
sh """ #!/bin/bash
cd "rule-based"
${scannerHome}/bin/sonar-scanner
"""
}
}
}
stage('Build docker images') {
when {
allOf {
// Triggered on every tag
expression{tag "*"}
}
}
steps {
sh "cd rule-based; docker build -t rule_based_refactorer -f Dockerfile ."
sh "cd perf-predictor-api; docker build -t fo_perf_predictor_api -f Dockerfile ."
sh "cd forecast-api; docker build -t forecast-api -f Dockerfile ."
sh "cd made-api; docker build -t made-api -f Dockerfile ."
}
}
stage('Push Dockerfile to DockerHub') {
when {
allOf {
// Triggered on every tag
expression{tag "*"}
}
}
steps {
withDockerRegistry(credentialsId: 'jenkins-sodalite.docker_token', url: '') {
sh """#!/bin/bash
docker tag rule_based_refactorer sodaliteh2020/rule_based_refactorer:${BUILD_NUMBER}
docker tag rule_based_refactorer sodaliteh2020/rule_based_refactorer
docker push sodaliteh2020/rule_based_refactorer:${BUILD_NUMBER}
docker push sodaliteh2020/rule_based_refactorer
docker tag fo_perf_predictor_api sodaliteh2020/fo_perf_predictor_api:${BUILD_NUMBER}
docker tag fo_perf_predictor_api sodaliteh2020/fo_perf_predictor_api
docker push sodaliteh2020/fo_perf_predictor_api:${BUILD_NUMBER}
docker push sodaliteh2020/fo_perf_predictor_api
docker tag forecast-api sodaliteh2020/forecast-api:${BUILD_NUMBER}
docker tag forecast-api sodaliteh2020/forecast-api
docker push sodaliteh2020/forecast-api:${BUILD_NUMBER}
docker push sodaliteh2020/forecast-api
docker tag made-api sodaliteh2020/made-api:${BUILD_NUMBER}
docker tag made-api sodaliteh2020/made-api
docker push sodaliteh2020/made-api:${BUILD_NUMBER}
docker push sodaliteh2020/made-api
"""
}
}
}
}
post {
failure {
slackSend (color: '#FF0000', message: "FAILED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})")
}
fixed {
slackSend (color: '#6d3be3', message: "FIXED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})")
}
}
}