-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathJenkinsfile
95 lines (84 loc) · 3.44 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
elifePipeline {
def commit
DockerImage image
stage 'Checkout', {
checkout scm
commit = elifeGitRevision()
}
node('containers-jenkins-plugin') {
stage 'Build images', {
checkout scm
commit = elifeGitRevision()
commitShort = elifeGitRevision().substring(0, 8)
branch = sh(script: 'git rev-parse --abbrev-ref HEAD', returnStdout: true).trim()
timestamp = sh(script: 'date --utc +%Y%m%d.%H%M', returnStdout: true).trim()
sh "find build/critical-css -name '*.css' -type f -delete"
dockerComposeBuild commit
}
stage 'Project tests', {
sh "IMAGE_TAG=${commit} docker-compose -f docker-compose.yml -f docker-compose.ci.yml up -d"
dockerComposeProjectTestsParallel('journal', commit, [
'phpunit': '/srv/journal/build/ci/phpunit/*.xml',
'behat': '/srv/journal/build/ci/behat/*.xml'
])
dockerComposeSmokeTests(commit, [
'services': [
'app': './smoke_tests.sh',
],
'blackbox': [
'./smoke_tests.sh localhost 8080',
]
])
}
stage 'Generate critical CSS', {
try {
sh "IMAGE_TAG=${commit} docker-compose -f docker-compose.yml -f docker-compose.ci.yml run --name=journal_critical_css critical_css"
sh "docker cp journal_critical_css:build/critical-css/. build/critical-css/"
} finally {
sh "docker cp journal_app_1:/srv/journal/var/logs/demo.json.log build/demo.json.log"
archiveArtifacts artifacts: "build/demo.json.log", fingerprint: true
sh "docker-compose -f docker-compose.yml -f docker-compose.ci.yml rm -v --stop --force"
}
}
stage 'Rebuild app image', {
sh "IMAGE_TAG=${commit} docker-compose -f docker-compose.yml -f docker-compose.ci.yml build app"
}
stage 'Push app image', {
image = DockerImage.elifesciences(this, "journal", commit)
image.tag("${branch}-${commitShort}-${timestamp}").push()
elifePullRequestOnly {
def branchName = env.CHANGE_BRANCH
def tagName = branchName.replaceAll("/", "_")
image.tag(tagName).push()
}
elifeMainlineOnly {
image.push()
}
}
}
elifeMainlineOnly {
stage 'Deploy on continuumtest, continuumtestpreview', {
def deployments = [
continuumtest: {
lock('journal--continuumtest') {
builderDeployRevision 'journal--continuumtest', commit
builderSmokeTests 'journal--continuumtest', '/srv/journal'
}
},
continuumtestpreview: {
lock('journal--continuumtestpreview') {
builderDeployRevision 'journal--continuumtestpreview', commit
builderSmokeTests 'journal--continuumtestpreview', '/srv/journal'
}
}
]
parallel deployments
}
stage 'Approval', {
elifeGitMoveToBranch commit, 'approved'
node('containers-jenkins-plugin') {
image.pull().tag('approved').push()
}
}
}
}