forked from gravitational/gravity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
118 lines (116 loc) · 4.11 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
112
113
114
115
116
117
118
#!/usr/bin/env groovy
def propagateParamsToEnv() {
for (param in params) {
if (env."${param.key}" == null) {
env."${param.key}" = param.value
}
}
}
properties([
disableConcurrentBuilds(),
parameters([
choice(choices: ["run", "skip"].join("\n"),
defaultValue: 'run',
description: 'Run or skip robotest system wide tests.',
name: 'RUN_ROBOTEST'),
choice(choices: ["true", "false"].join("\n"),
defaultValue: 'true',
description: 'Destroy all VMs on success.',
name: 'DESTROY_ON_SUCCESS'),
choice(choices: ["true", "false"].join("\n"),
defaultValue: 'true',
description: 'Destroy all VMs on failure.',
name: 'DESTROY_ON_FAILURE'),
choice(choices: ["true", "false"].join("\n"),
defaultValue: 'true',
description: 'Abort all tests upon first failure.',
name: 'FAIL_FAST'),
choice(choices: ["gce"].join("\n"),
defaultValue: 'gce',
description: 'Cloud provider to deploy to.',
name: 'DEPLOY_TO'),
string(name: 'PARALLEL_TESTS',
defaultValue: '4',
description: 'Number of parallel tests to run.'),
string(name: 'REPEAT_TESTS',
defaultValue: '1',
description: 'How many times to repeat each test.'),
string(name: 'ROBOTEST_VERSION',
defaultValue: 'stable-gce',
description: 'Robotest tag to use.'),
choice(choices: ["true", "false"].join("\n"),
defaultValue: 'true',
description: 'Whether to use preemptible VMs.',
name: 'GCE_PREEMPTIBLE'),
choice(choices: ["custom-4-8192", "custom-8-8192"].join("\n"),
defaultValue: 'custom-8-8192',
description: 'VM type to use.',
name: 'GCE_VM'),
]),
])
timestamps {
node {
stage('checkout') {
checkout scm
sh "git submodule update --init --recursive"
sh "sudo git clean -ffdx" // supply -f flag twice to force-remove untracked dirs with .git subdirs (e.g. submodules)
}
stage('params') {
echo "${params}"
propagateParamsToEnv()
}
stage('clean') {
sh "make -C e clean"
}
stage('build-gravity') {
withCredentials([
[$class: 'SSHUserPrivateKeyBinding', credentialsId: '08267d86-0b3a-4101-841e-0036bf780b11', keyFileVariable: 'GITHUB_SSH_KEY'],
[
$class: 'UsernamePasswordMultiBinding',
credentialsId: 'jenkins-aws-s3',
usernameVariable: 'AWS_ACCESS_KEY_ID',
passwordVariable: 'AWS_SECRET_ACCESS_KEY',
],
]) {
sh 'make -C e production telekube opscenter'
}
}
}
throttle(['robotest']) {
node {
stage('build-and-test') {
parallel (
build : {
withCredentials([
[$class: 'SSHUserPrivateKeyBinding', credentialsId: '08267d86-0b3a-4101-841e-0036bf780b11', keyFileVariable: 'GITHUB_SSH_KEY']]) {
sh 'make test && make -C e test'
}
},
robotest : {
if (params.RUN_ROBOTEST == 'run') {
withCredentials([
[
$class: 'UsernamePasswordMultiBinding',
credentialsId: 'jenkins-aws-s3',
usernameVariable: 'AWS_ACCESS_KEY_ID',
passwordVariable: 'AWS_SECRET_ACCESS_KEY'
],
[$class: 'StringBinding', credentialsId: 'GET_GRAVITATIONAL_IO_APIKEY', variable: 'GET_GRAVITATIONAL_IO_APIKEY'],
[$class: 'FileBinding', credentialsId:'ROBOTEST_LOG_GOOGLE_APPLICATION_CREDENTIALS', variable: 'GOOGLE_APPLICATION_CREDENTIALS'],
[$class: 'FileBinding', credentialsId:'OPS_SSH_KEY', variable: 'SSH_KEY'],
[$class: 'FileBinding', credentialsId:'OPS_SSH_PUB', variable: 'SSH_PUB'],
]) {
sh """
make -C e robotest-run-suite \
AWS_KEYPAIR=ops \
AWS_REGION=us-east-1 \
ROBOTEST_VERSION=$ROBOTEST_VERSION"""
}
}else {
echo 'skipped system tests'
}
} )
}
}
}
}