This repository was archived by the owner on Dec 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfailed.jenkinsfile
100 lines (86 loc) · 3.93 KB
/
failed.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
#!/usr/bin/env groovy
/***************************************************************************
*
* (C) Copyright IBM Corp. 2018
*
* This program and the accompanying materials are made available
* under the terms of the Apache License v2.0 which accompanies
* this distribution.
*
* The Apache License v2.0 is available at
* http://www.opensource.org/licenses/apache2.0.php
*
* Contributors:
* Multiple authors (IBM Corp.) - initial implementation and documentation
***************************************************************************/
properties([
parameters([
choice(name: 'CITGM_LOGLEVEL', choices: 'verbose\ninfo\nwarn\nsilly\nerror', defaultValue: 'verbose', description: 'This defines log level for CITGM.'),
string(defaultValue: "refs/heads/master", description: 'The remote portion of the Git refspec to fetch and test PR - refs/pull/PR_NUMBER/head', name: 'GIT_REMOTE_REF'),
string(defaultValue: "module-curation.eu-gb.mybluemix.net", description: 'module-curation-development.stage1.eu-gb.mybluemix.net || module-curation.eu-gb.mybluemix.net || IP:PORT', name: 'HOST')
]),
])
withCredentials([usernamePassword(credentialsId: 'fb878c0f-2ce4-4759-9953-cfc36d59cf9b',
usernameVariable: 'API_USERNAME', passwordVariable: 'PASSWORD')]) {
stage('PRE-CLEANUP') {
node ('linux && x64') {
checkout scm
withEnv(["HOST=${params.HOST}", "API_USERNAME=${env.API_USERNAME}", "PASSWORD=${env.PASSWORD}", "GIT_REMOTE_REF=${params.GIT_REMOTE_REF}"]){
env.citgm_parameters = sh (
script: "./clean-data.sh"
)
}
}
}
stage('MC-CITGM (Test)') {
/* - Check for new node/module version and add them to the database
- Find missing test results and return params for MC-CITGM */
node ('linux && x64') {
checkout scm
withEnv(["HOST=${params.HOST}", "API_USERNAME=${env.API_USERNAME}", "PASSWORD=${env.PASSWORD}", "GIT_REMOTE_REF=${params.GIT_REMOTE_REF}"]){
env.citgm_parameters = sh (
returnStdout: true,
script: "./failed-test.sh"
)
}
}
println "\n\n${env.citgm_parameters}\n\n"
def resp = env.citgm_parameters.trim().tokenize('%') // Create an array of parameters
// Create an array of buildJobs to run in parallel
def buildJobs = [:]
resp.each { str ->
def p = str.tokenize(',')
def module = "${p[0]}", module_version = "${p[1]}", node_version = "${p[2]}"
def os = "${p[3]}", arch = "${p[4]}", distro = "${p[5]}"
def parameters = []
parameters.push(string(name: 'MODULE', value: module))
parameters.push(string(name: 'MODULE_VERSION', value: module_version))
parameters.push(string(name: 'NODE_VERSION', value: node_version))
parameters.push(string(name: 'HOST', value: params.HOST))
parameters.push(string(name: 'OSS', value: os))
parameters.push(string(name: 'ARCHS', value: arch))
parameters.push(string(name: 'DISTROS', value: distro))
parameters.push(string(name: 'GIT_REMOTE_REF', value: params.GIT_REMOTE_REF))
// parameters.push(string(name: 'CITGM_LOGLEVEL', value: params.CITGM_LOGLEVEL))
buildJobs["$module@$module_version-$node_version($os $arch $distro)"] = { build(job: "MC-CITGM", parameters: parameters, propagate: false) }
}
def results = parallel(buildJobs)
def msg = '\nRESULTS:\n'
results.each { res ->
msg += "${res.key}: ${results[res.key].result}\n"
currentBuild.result = results[res.key].result
}
println msg
}
stage('POST-CLEANUP') {
node ('linux && x64') {
checkout scm
withEnv(["HOST=${params.HOST}", "API_USERNAME=${env.API_USERNAME}", "PASSWORD=${env.PASSWORD}", "GIT_REMOTE_REF=${params.GIT_REMOTE_REF}"]){
env.citgm_parameters = sh (
script: "./clean-data.sh"
)
}
}
}
println "\n\n \\(• ◡ •)/ Pipeline COMPLETE \\(• ◡ •)/\n\n"
}