-
Notifications
You must be signed in to change notification settings - Fork 83
/
Jenkinsfile
80 lines (74 loc) · 2.19 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
def jobProperties = [
buildDiscarder(logRotator(numToKeepStr: '50', artifactNumToKeepStr: '5')),
disableConcurrentBuilds(abortPrevious: true)
]
if (env.BRANCH_IS_PRIMARY) {
jobProperties << pipelineTriggers([cron('@weekly')]) // Run at least weekly on the primary branch to assure we test recent releases
}
properties(jobProperties)
podTemplate(
inheritFrom: 'jnlp-maven-17',
workingDir: '/home/jenkins/agent',
containers: [
containerTemplate(name: 'jnlp', image: 'jenkinsciinfra/packaging:latest')
],
envVars: [
envVar(key: 'HOME', value: '/home/jenkins/agent/workspace'),
],
) {
nodeWithTimeout(POD_LABEL) {
withEnv([
"BUILDENV=${WORKSPACE}/env/test.mk",
"BRANDING_DIR=${WORKSPACE}/branding",
"BRAND=${WORKSPACE}/branding/jenkins.mk",
"GPG_FILE=${WORKSPACE}/credentials/sandbox.gpg",
"GPG_KEYNAME=Bogus Test",
"GPG_PASSPHRASE=s3cr3t",
"GPG_PASSPHRASE_FILE=${WORKSPACE}/credentials/test.gpg.password.txt",
"HOME=/home/jenkins/agent/workspace",
"WAR=${WORKSPACE}/jenkins.war",
"MSI=${WORKSPACE}/jenkins.msi",
"RELEASELINE=-experimental",
]) {
stage('Preparation') {
checkout scm
sh './prep.sh'
}
stage('Build') {
sh 'make package && python3 -m pytest bin --junitxml target/junit.xml'
junit 'target/junit.xml'
def results = '*.war, target/debian/*.deb, target/rpm/*.rpm, target/suse/*.rpm'
stash includes: results, name: 'results'
archiveArtifacts results
}
}
}
}
nodeWithTimeout('docker') {
stage('Test') {
checkout scm
unstash 'results'
infra.withDockerCredentials {
ansiColor('xterm') {
sh '''
cat /proc/cpuinfo
cat /proc/meminfo
python3 -m venv venv
. venv/bin/activate
pip install -U pip wheel
pip install -r requirements.txt
ANSIBLE_FORCE_COLOR=true molecule test
ANSIBLE_FORCE_COLOR=true molecule test -s servlet
deactivate
'''.stripIndent()
}
}
}
}
void nodeWithTimeout(String label, Closure body) {
node(label) {
timeout(time: 1, unit: 'HOURS') {
body()
}
}
}