/
Jenkinsfile
111 lines (99 loc) · 2.85 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
#!/usr/bin/env groovy
def repoPath = 'lap/avplayer'
pipeline {
agent {
label "docker"
}
environment {
COMPOSE_FILE = "docker-compose.ci.yml"
DOCKER_REPO = "containers.lib.berkeley.edu/${repoPath}/${env.GIT_BRANCH.toLowerCase()}"
DOCKER_TAG = "${DOCKER_REPO}:build-${BUILD_NUMBER}"
DOCKER_TAG_LATEST = "${DOCKER_REPO}:latest"
REGISTRY_CREDENTIALS = "0A792AEB-FA23-48AC-A824-5FF9066E6CA9"
}
stages {
stage("Build") {
steps {
withDockerRegistry(url: "https://${DOCKER_REPO}", credentialsId: "${REGISTRY_CREDENTIALS}") {
sh 'docker-compose build --pull'
sh 'docker push "${DOCKER_TAG}"'
}
}
}
stage("Test") {
stages {
stage("Run") {
steps {
sh 'docker-compose run --rm rails assets:precompile'
sh 'docker-compose up -d'
}
}
stage("Tests") {
parallel {
stage("RSpec") {
steps {
// Run the tests
sh 'docker-compose run --rm rails cal:test:ci'
}
}
stage("Rubocop") {
steps {
sh 'docker-compose run --rm rails cal:test:rubocop'
}
}
stage("Brakeman") {
steps {
sh 'docker-compose run --rm rails brakeman'
}
}
stage("Audit") {
steps {
sh 'docker-compose run --rm rails bundle:audit'
}
}
}
post {
always {
sh 'docker cp "$(docker-compose ps -q rails):/opt/app/tmp/reports" tmp/reports'
junit 'tmp/reports/specs/*.xml'
publishBrakeman 'tmp/reports/brakeman/brakeman.json'
publishHTML([
reportName: 'Code Coverage',
allowMissing: false,
alwaysLinkToLastBuild: false,
keepAll: true,
reportDir: 'tmp/reports/rcov',
reportFiles: 'index.html',
])
publishHTML([
reportName: 'Rubocop',
allowMissing: false,
alwaysLinkToLastBuild: false,
keepAll: true,
reportDir: 'tmp/reports/rubocop',
reportFiles: 'index.html',
])
}
}
}
}
post {
always {
sh 'docker-compose down -v --remove-orphans || true'
}
}
}
stage("Push") {
steps {
withDockerRegistry(url: "https://${DOCKER_REPO}", credentialsId: "${REGISTRY_CREDENTIALS}") {
sh 'docker tag "${DOCKER_TAG}" "${DOCKER_TAG_LATEST}"'
sh 'docker push "${DOCKER_TAG_LATEST}"'
}
}
}
}
options {
ansiColor("xterm")
timeout(time: 10, unit: "MINUTES")
}
}