forked from GovReady/govready-q
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
50 lines (46 loc) · 2.06 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
pipeline {
agent {
docker {
image 'python:3'
args '-p 8001:8001 --network continuousato'
}
}
stages {
stage('OS Setup') {
steps {
sh 'apt-get update && apt-get install -y graphviz unzip pandoc jq locales && apt-get clean'
// don't install wkhtmltopdf by default, because of security concerns
// sh 'apt-get update && apt-get install -y wkhtmltopdf && apt-get clean'
sh 'sed -i "s/^[# ]*en_US.UTF-8/en_US.UTF-8/" /etc/locale.gen'
sh '/usr/sbin/locale-gen'
}
}
stage('Build App') {
steps {
sh 'pip install -r requirements.txt'
sh './fetch-vendor-resources.sh'
}
}
stage('Test App') {
steps {
// Leaving out siteapp tests for now, because selenium/chromium isn't working. See govready-q/issues/334
// Run tests, saving results to a temporary file that will be uploaded
// to the GovReady-Q Compliance Server. Python unittest output goes
// primarily to standard error, so redirect it to standard output before
// using tee to get it into a file.
sh './manage.py test guidedmodules 2>&1 | tee /tmp/pytestresults.txt'
// Since we're uploading the test into a longtext field, which is expected
// to be markdown, add hard line breaks.
sh 'sed -i s/$/\\\\\\\\/ /tmp/pytestresults.txt'
sh 'echo >> /tmp/pytestresults.txt' // add blank line because trailing \ is not valid as a hard break
sh 'echo >> /tmp/pytestresults.txt' // add blank line because trailing \ is not valid as a hard break
withCredentials([string(credentialsId: 'govready_q_api_url', variable: 'Q_API_URL'), string(credentialsId: 'govready_q_api_key', variable: 'Q_API_KEY')]) {
// Send hostname.
sh 'curl -F project.file_server.hostname=$(hostname) --header "Authorization:$Q_API_KEY" $Q_API_URL'
// Send test results.
sh 'curl -F "project.file_server.login_message=</tmp/pytestresults.txt" --header "Authorization:$Q_API_KEY" $Q_API_URL'
}
}
}
}
}