forked from rook/rook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
108 lines (99 loc) · 3.73 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
// Rook build for Jenkins Pipelines
pipeline {
agent { label 'ec2-stateful' }
options {
disableConcurrentBuilds()
timeout(time: 2, unit: 'HOURS')
timestamps()
}
stages {
stage('Build') {
steps {
sh 'build/run make -j\$(nproc) build.all'
}
}
stage('Unit Tests') {
steps {
sh 'build/run make -j\$(nproc) test'
}
}
stage('Integration Tests') {
steps{
sh 'tests/scripts/makeTestImages.sh save amd64'
stash name: 'repo-amd64',includes: 'rook-amd64.tar,build/common.sh,_output/tests/linux_amd64/,tests/scripts/'
script{
def data = [
"aws_ci": "v1.6.7",
"gce_ci": "v1.7.2"
]
testruns = [:]
for (kv in mapToList(data)) {
testruns[kv[0]] = RunIntegrationTest(kv[0], kv[1])
}
parallel testruns
}
}
}
stage('Publish') {
environment {
DOCKER = credentials('rook-docker-hub')
QUAY = credentials('rook-quay-io')
AWS = credentials('rook-jenkins-aws')
GIT = credentials('rook-github')
}
steps {
sh 'docker login -u="${DOCKER_USR}" -p="${DOCKER_PSW}"'
sh 'docker login -u="${QUAY_USR}" -p="${QUAY_PSW}" quay.io'
sh 'build/run make -j\$(nproc) -C build/release build BRANCH_NAME=${BRANCH_NAME} GIT_API_TOKEN=${GIT_PSW}'
sh 'build/run make -j\$(nproc) -C build/release publish BRANCH_NAME=${BRANCH_NAME} AWS_ACCESS_KEY_ID=${AWS_USR} AWS_SECRET_ACCESS_KEY=${AWS_PSW} GIT_API_TOKEN=${GIT_PSW}'
sh '[ "${BRANCH_NAME}" != "master" ] || build/run make -j\$(nproc) -C build/release promote BRANCH_NAME=master CHANNEL=master AWS_ACCESS_KEY_ID=${AWS_USR} AWS_SECRET_ACCESS_KEY=${AWS_PSW}'
}
}
}
post {
always {
archive '_output/tests/*'
junit allowEmptyResults: true, keepLongStdio: true, testResults: '_output/tests/*.xml'
sh 'make -j\$(nproc) clean'
sh 'make -j\$(nproc) prune PRUNE_HOURS=48 PRUNE_KEEP=48'
sh 'make -j\$(nproc) -C build/release clean'
deleteDir()
}
}
}
def RunIntegrationTest(k, v) {
return {
node("${k}") {
script{
try{
withEnv(["KUBE_VERSION=${v}"]){
unstash 'repo-amd64'
echo "running tests on k8s version ${v}"
sh 'tests/scripts/makeTestImages.sh load amd64'
sh "tests/scripts/kubeadm.sh up"
try{
sh '''#!/bin/bash
set -o pipefail
export KUBECONFIG=$HOME/admin.conf
kubectl config view
kubectl create clusterrolebinding anon-user-access --clusterrole cluster-admin --user system:anonymous
_output/tests/linux_amd64/smoke -test.v -test.timeout 1200s 2>&1 | tee _output/tests/integrationTests.log'''
}
finally{
sh "mv _output/tests/integrationTests.log _output/tests/${k}_${v}_integrationTests.log"
}
}
}
finally{
archive '_output/tests/*.log'
deleteDir()
}
}
}
}
}
// Required due to JENKINS-27421
@NonCPS
List<List<?>> mapToList(Map map) {
return map.collect { it ->[it.key, it.value]}
}