-
Notifications
You must be signed in to change notification settings - Fork 138
/
cloud-gating.Jenkinsfile
128 lines (113 loc) · 4.09 KB
/
cloud-gating.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
119
120
121
122
123
124
125
126
127
128
/**
* The cloud-gating Jenkins Pipeline
*/
def ardana_lib = null
pipeline {
// skip the default checkout, because we want to use a custom path
options {
skipDefaultCheckout()
timestamps()
}
agent {
node {
label 'cloud-ci-trigger'
customWorkspace "${JOB_NAME}-${BUILD_NUMBER}"
}
}
stages {
stage('Setup workspace') {
steps {
script {
env.staging_url = "http://provo-clouddata.cloud.suse.de/repos/x86_64/SUSE-OpenStack-Cloud-${version}-devel-staging/media.1/build"
env.staging_build = sh (
returnStdout: true,
script: "wget -q -O - $staging_url | grep -oP 'Build[0-9]+'"
).trim()
currentBuild.displayName = "#${BUILD_NUMBER}: ${staging_build}"
sh('''
git clone $git_automation_repo --branch $git_automation_branch automation-git
''')
env.starttime = sh (
returnStdout: true,
script: '''
rfcdate="$( curl -sI $staging_url | grep 'Last-Modified: ' | head -n1 | cut -d' ' -f2- )"
epoch=$(date +%s -d "$rfcdate")
if test "$epoch" -lt "1400000000"; then
echo "Last-Modified epoch is too low to be valid."
exit 1
fi
echo $epoch
'''
).trim()
cloud_lib = load "$WORKSPACE/automation-git/jenkins/ci.suse.de/pipelines/openstack-cloud.groovy"
cloud_lib.load_extra_params_as_vars(extra_params)
}
}
}
stage('Trigger jobs') {
// Do not abort all stages if one of them fails
failFast false
steps {
script {
def parallelJobMap = cloud_lib.generate_parallel_stages(
["SOC" + version, "SOCC" + version],
[],
"$WORKSPACE/automation-git/jenkins/ci.suse.de/pipelines/cloud-gating-config.yml") {
job_title, job_def ->
// reserve a resource here for the integration job, to avoid
// keeping a cloud-ci worker busy while waiting for a
// resource to become available.
cloud_lib.run_with_reserved_env(true, cloud_env, null) {
reserved_env ->
def job_params = [
cloud_env : reserved_env,
reserve_env : false,
rc_notify : false,
cleanup : "on success",
git_automation_repo : git_automation_repo,
git_automation_branch: git_automation_branch
]
// override default parameters with those loaded from config file
job_params.putAll(job_def.job_params)
// combine together extra_params from this job with those loaded from config file
combined_extra_params = [extra_params, job_def.job_params.extra_params?: ""].join('\n').trim()
if (!combined_extra_params.isEmpty()) {
job_params.extra_params = combined_extra_params
}
cloud_lib.trigger_build(job_def.job_name, cloud_lib.convert_to_build_params(job_params), false)
}
}
if (parallelJobMap.isEmpty()) {
def errorMsg = "ERROR: No jobs found that matched the SOC${version} and SOCC${version} cloud versions."
echo errorMsg
error(errorMsg)
}
parallel parallelJobMap
}
}
}
stage('Submit project') {
when {
expression { skip_submit_project == 'false' }
}
steps {
script{
cloud_lib.trigger_build("openstack-submit-project", [
string(name: 'project', value: "Devel:Cloud:${version}"),
string(name: 'starttime', value: "${starttime}"),
string(name: 'subproject', value: "Staging"),
// for unified gated we want everything white listed
// and nothing black listed.
string(name: 'package_whitelist', value: ""),
string(name: 'package_blacklist', value: "")
])
}
}
}
}
post {
cleanup {
cleanWs()
}
}
}