forked from raisedhand/via
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
93 lines (82 loc) · 1.97 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
/**
* This app's Jenkins Pipeline.
*
* This is written in Jenkins Scripted Pipeline language.
* For docs see:
* https://jenkins.io/doc/book/pipeline/syntax/#scripted-pipeline
*/
// Import the Hypothesis shared pipeline library, which is defined in this
// repo: https://github.com/hypothesis/pipeline-library
@Library("pipeline-library") _
// The the built hypothesis/via Docker image.
def img
node {
// The args that we'll pass to Docker run each time we run the Docker
// image.
runArgs = "-u root -e SITE_PACKAGES=true"
stage("Build") {
// Checkout the commit that triggered this pipeline run.
checkout scm
// Build the Docker image.
img = buildApp(name: "hypothesis/via")
}
stage("Tests") {
testApp(image: img, runArgs: "${runArgs}") {
installDeps()
run("make functests")
}
}
onlyOnMaster {
stage("release") {
releaseApp(image: img)
}
}
}
onlyOnMaster {
milestone()
stage("Deploy (qa)") {
lock("qa deploy") {
parallel(
lms: {
sleep 2
deployApp(image: img, app: "lms-via", env: "qa")
},
public: {
deployApp(image: img, app: "via", env: "qa")
}
)
}
}
milestone()
stage("Approval") {
input(message: "Proceed to production deploy?")
}
milestone()
stage("Deploy (prod)") {
lock("prod deploy") {
parallel(
lms: {
sleep 2
deployApp(image: img, app: "lms-via", env: "prod")
},
public: {
deployApp(image: img, app: "via", env: "prod")
}
)
}
}
}
/**
* Install some common system dependencies.
*
* These are test dependencies that're need to run most of the stages above
* (tests, lint, ...) but that aren't installed in the production Docker image.
*/
def installDeps() {
sh "pip3 install -q tox>=3.8.0"
}
/** Run the given command. */
def run(command) {
sh "apk add build-base"
sh "cd /var/lib/hypothesis && ${command}"
}