This repository has been archived by the owner on Apr 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
105 lines (97 loc) · 2.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
94
95
96
97
98
99
100
101
102
103
104
105
pipeline {
agent {
label 'sbt-slave'
}
environment {
// Ensure that build scripts recognise the environment they are running within
CI = 'jenkins'
// Use the git SHA to gain some integration test isolation
DOCKER_COMPOSE_PROJECT_NAME = sh(returnStdout: true, script: "git rev-parse --verify HEAD").trim()
}
stages {
stage('GenerateTemplate') {
steps {
ansiColor('xterm') {
script {
sh "mkdir template.g8; cp -fr src template.g8/"
sh "sbt cakeNew file://./template.g8 --name=akkarepo --project_description=ci-test --organisation_domain=test_net --organisation=test_cakesolutions"
def checkDirectory = sh(returnStdout: true, script: "if [ -d ./akkarepo/mains/server/src/main/scala/test_net/test_cakesolutions/akkarepo ]; then echo 'OK'; else echo 'NOK'; fi").trim()
if (checkDirectory == 'NOK') error("Template parameters can not be applied correctly!")
}
}
}
}
stage('Environment') {
steps {
ansiColor('xterm') {
dir("akkarepo") {
script {
sh "sbt checkExternalBuildTools"
sh "sbt dockerComposeConfigCheck"
sh "sbt dockerComposeDown"
sh "docker images"
sh "docker ps -a"
}
}
}
}
}
stage('Compile') {
steps {
ansiColor('xterm') {
dir("akkarepo") {
script {
sh "sbt clean compile test:compile it:compile doc"
}
}
}
}
}
stage('Verification') {
steps {
ansiColor('xterm') {
dir("akkarepo") {
script {
// Since copyright headers are not set up for test projects, we omit headerCheck, test:headerCheck and it:headerCheck here
sh "sbt scalastyle test:scalastyle it:scalastyle sbt:scalafmt::test scalafmt::test test:scalafmt::test it:scalafmt::test"
}
}
}
}
}
stage('Test') {
steps {
ansiColor('xterm') {
dir("akkarepo") {
script {
// We intentionally avoid any coverage based checks
sh "sbt test"
}
}
}
}
}
stage('IntegrationTest') {
steps {
ansiColor('xterm') {
dir("akkarepo") {
script {
// In CI environments, we use the eth0 or local-ipv4 address of the slave
// instead of localhost
try {
sh "sbt dockerComposeUp"
def dockerip = sh(returnStdout: true, script: $/wget http://169.254.169.254/latest/meta-data/local-ipv4 -qO-/$).trim()
withEnv(["CI_HOST=$dockerip"]) {
sh "sbt it:test"
}
} finally {
sh "sbt dockerComposeDown"
}
}
}
}
}
}
// We intentionally perform no publish step
}
}