-
Notifications
You must be signed in to change notification settings - Fork 63
/
Jenkinsfile
141 lines (136 loc) · 5.17 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
#!groovy
pipeline {
agent any
parameters {
string(
name: 'STATUS_EMAIL',
defaultValue: '${DEFAULT_RECIPIENTS}',
description: 'Comma sep list of email addresses that should recieve test status notifications.')
}
options {
timeout(time: 1, unit: 'HOURS')
}
environment {
LOCAL_PENNAI_DEPLOY_DIR = '/data/git/Aliro'
LOCAL_PENNAI_DEPLOY_FILE = "${LOCAL_PENNAI_DEPLOY_DIR}/docker-compose.yml"
}
stages {
stage('Checkout') {
steps {
cleanWs()
// checkout
checkout scm
dir ('target/ai_docs') {echo 'target/ai_docs'}
dir ('target/test-reports/cobertura') {echo 'target/test-reports/cobertura'}
}
}
stage('Build Docs') {
agent {
dockerfile {
filename 'docs/Dockerfile'
dir '.'
args '-u root'
}
}
steps {
sh 'rm -fdr target'
dir ('docs') {
sh 'make html'
}
}
post {
always {
stash includes: 'target/**', name: 'docs-python'
}
}
}
stage('Unit Tests') {
steps {
sh 'rm -fdr target'
sh 'docker-compose -f ./docker-compose-unit-test.yml build -m 6g'
sh 'docker-compose -f ./docker-compose-unit-test.yml up --abort-on-container-exit --force-recreate'
}
post {
always {
stash includes: 'target/**', name: 'testresult-unittest'
}
}
}
stage('Rebuild') {
steps {
// rebuild
sh 'cp config/ai.env-template config/ai.env'
sh 'docker-compose build -m 6g'
}
}
stage('Stop Aliro Locally') {
steps {
sh "docker-compose -f ${LOCAL_PENNAI_DEPLOY_FILE} stop"
}
}
stage('Integration Tests') {
steps {
// stop any running Aliro test or dev instances
sh 'docker-compose -f ./docker-compose-int-test.yml stop'
// run the integration test instance
sh 'docker-compose -f ./docker-compose-int-test.yml build -m 6g'
sh 'docker-compose -f ./docker-compose-int-test.yml up --abort-on-container-exit --force-recreate'
}
post {
always {
stash includes: 'target/**', name: 'testresult-inttest'
}
}
}
stage('Start Aliro Locally') {
steps {
sh "docker-compose -f ${LOCAL_PENNAI_DEPLOY_FILE} up --detach --force-recreate"
}
}
}
post {
always {
sh '(cd target && ls -lR)'
cleanWs()
unstash 'docs-python'
unstash 'testresult-unittest'
unstash 'testresult-inttest'
junit 'target/test-reports/*.xml'
cobertura autoUpdateHealth: false, autoUpdateStability: false, coberturaReportFile: 'target/test-reports/cobertura/nose_cover.xml', conditionalCoverageTargets: '70, 0, 0', failUnhealthy: false, failUnstable: false, lineCoverageTargets: '80, 0, 0', maxNumberOfBuilds: 0, methodCoverageTargets: '80, 0, 0', onlyStable: false, sourceEncoding: 'ASCII', zoomCoverageChart: false
publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: false, reportDir: 'target/ai_docs/html', reportFiles: 'index.html, search.html, py-modindex.html', reportName: 'AI docs', reportTitles: ''])
}
failure {
echo 'Pipeline Failure'
emailext attachLog: false,
compressLog: false,
subject: 'Job \'${JOB_NAME}\' (${BUILD_NUMBER}) failure',
body: '''${SCRIPT, template="groovy-html.template"}''',
mimeType: 'text/html',
to: "${params.STATUS_EMAIL}",
//recipientProviders: [culprits()],
replyTo: "${params.STATUS_EMAIL}"
}
unstable {
echo 'Pipeline Unstable'
emailext attachLog: false,
compressLog: false,
subject: 'Job \'${JOB_NAME}\' (${BUILD_NUMBER}) unstable',
body: '''${SCRIPT, template="groovy-html.template"}''',
mimeType: 'text/html',
to: "${params.STATUS_EMAIL}",
//recipientProviders: [culprits()],
replyTo: "${params.STATUS_EMAIL}"
}
fixed {
echo 'Pipeline is back to normal'
emailext attachLog: false,
compressLog: false,
subject: 'Job \'${JOB_NAME}\' (${BUILD_NUMBER}) is back to normal',
body: '''${SCRIPT, template="groovy-html.template"}''',
mimeType: 'text/html',
to: "${params.STATUS_EMAIL}",
//recipientProviders: [culprits()],
replyTo: "${params.STATUS_EMAIL}"
}
}
}