This repository was archived by the owner on May 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
107 lines (91 loc) · 3.17 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
def scenarios = [
// "ubuntu1804" : [
// ["setup", "install"],
// ["setup", "scaleup"],
// ["setup", "scaledown"],
// ["use", "deploy"],
// ["use", "undeploy"],
// ["setup", "uninstall"],
// ],
// "ubuntu2004": [
// ["setup", "install"],
// ["setup", "scaleup"],
// ["setup", "scaledown"],
// ["use", "deploy"],
// ["use", "undeploy"],
// ["setup", "uninstall"],
// ],
"ubuntu2204" : [
["setup", "install"],
["setup", "scaleup"],
["setup", "scaledown"],
["use", "deploy"],
["use", "undeploy"],
["setup", "uninstall"],
],
// "centos7" : [
// ["setup", "install"],
// ["setup", "scaleup"],
// ["setup", "scaledown"],
// ["use", "deploy"],
// ["use", "undeploy"],
// ["setup", "uninstall"],
// ],
// "centos8" : [
// ["setup", "install"],
// ["setup", "scaleup"],
// ["setup", "scaledown"],
// ["use", "deploy"],
// ["use", "undeploy"],
// ["setup", "uninstall"],
// ]
]
parallel_stages = [:]
for (kv in mapToList(scenarios)) {
def platform = kv[0]
def testList = kv[1]
parallel_stages[platform] = {
docker.image('fabos4ai/molecule:4.0.1').inside('-u root') {
try {
stage("${platform} - Dependencies") {
sh "ansible-galaxy install -f -r requirements.yml"
}
stage("${platform} - Destroy") {
sh "cd ./roles/setup && molecule destroy -s install-${platform}"
}
stage("${platform} - Create") {
// sh " cd ./roles/setup && molecule reset -s install-${platform} && molecule create -s install-${platform}"
sh " cd ./roles/setup && molecule create -s install-${platform}"
}
for (int i = 0; i < testList.size(); i++) {
def role = testList[i][0]
def scenario = testList[i][1]
stage("${platform} - ${scenario}") {
sh "cd ./roles/${role} && molecule -vv test -s ${scenario}-${platform} --destroy never"
}
}
}
finally {
stage("${platform} - Destroy") {
sh "cd ./roles/setup && molecule destroy -s install-${platform}"
}
}
}
}
}
node {
checkout scm
withCredentials([usernamePassword(
credentialsId: 'jenkins_infra_account',
usernameVariable: 'VSPHERE_USER',
passwordVariable: 'VSPHERE_PASSWORD'
)]) {
parallel(parallel_stages)
}
}
@NonCPS
List<List<?>> mapToList(Map map) {
return map.collect { it ->
[it.key, it.value]
}
}