This repository was archived by the owner on Apr 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
105 lines (96 loc) · 3.88 KB
/
Jenkinsfile
File metadata and controls
105 lines (96 loc) · 3.88 KB
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
node() {
stage("Checkout source code") {
checkout([$class: 'GitSCM', branches: [[name: COMMITID]], userRemoteConfigs: [[url: 'https://github.com/dajudge/testee.fi.git']]])
}
withBuildEnv() {
stage("Build, Test and publish to Nexus") {
try {
sh 'gpg --import $GPG_KEY_FILE'
sh 'TESTEEFI_IGNORE_TEST_FAILURES=true TESTEEFI_SIGN_ARTIFACTS=true ./gradlew -Dorg.gradle.project.signing.keyId=CBC58EE1 -Dorg.gradle.project.signing.password=$GPG_PASSWORD -Dorg.gradle.project.signing.secretKeyRingFile=$HOME/.gnupg/secring.gpg --no-daemon clean build uploadArchives --stacktrace'
} finally {
junit "**/build/test-results/**/TEST-*.xml"
}
}
stage("Static code analysis") {
sh "./gradlew --no-daemon -x test sonarqube"
}
}
stage("Usage testing") {
@NonCPS def imageDirs = findFiles(glob:"usageTests/images/**/Dockerfile").collect { f ->
def split = f.path.split("/")
"${split[2]}:${split[3]}"
}
imageDirs.each { imageVersion ->
def dockerImage = dir("usageTests/images/${imageVersion.replace(":", "/")}") {
docker.build("testeefi-usage-$imageVersion")
}
def versionToTest = readFile("version.txt").trim()
dir("usageTests/maven/") {
dockerImage.inside {
withCredentials([
usernamePassword(
credentialsId: 'maven',
usernameVariable: 'MAVEN_USER',
passwordVariable: 'MAVEN_PASSWORD'
)]) {
sh "chmod 755 build.sh"
def status = sh(
script: "./build.sh $versionToTest",
returnStatus: true
)
if(status != 0) {
println "Script returned nonzero status, build is unstable"
currentBuild.result == 'UNSTABLE'
}
}
}
}
}
}
}
def withBuildEnv(closure) {
def jdkImage, psqlImage
dir("builder/jdk8") {
jdkImage = docker.build "testeefi-jdk8:latest"
}
dir("builder/psql") {
psqlImage = docker.build "testeefi-psql:latest"
}
def psqlContainer = "testeefi-psql-${System.currentTimeMillis()}"
psqlImage.withRun("--name $psqlContainer -e POSTGRES_DB=testeefi -e POSTGRES_PASSWORD=testeefi -e POSTGRES_USER=testeefi") {
jdkImage.inside(
[
"--link ${psqlContainer}:psql",
"-e TESTEEFI_PSQL_HOSTNAME=psql",
"-e TESTEEFI_PSQL_DB=testeefi",
"-e TESTEEFI_PSQL_USER=testeefi",
"-e TESTEEFI_PSQL_PASSWORD=testeefi"
].join(" "),
{
withCredentials([
file(
credentialsId: 'gpg-key',
variable: 'GPG_KEY_FILE'
),
usernamePassword(
credentialsId: 'gpg-password',
usernameVariable: 'GPG_USER', // not used
passwordVariable: 'GPG_PASSWORD'
),
usernamePassword(
credentialsId: 'maven',
usernameVariable: 'MAVEN_USER',
passwordVariable: 'MAVEN_PASSWORD'
),
usernamePassword(
credentialsId: 'sonar',
usernameVariable: 'SONAR_USER',
passwordVariable: 'SONAR_PASSWORD'
)
]) {
closure()
}
}
)
}
}