-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
96 lines (85 loc) · 2.28 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
def scenarios = [
"ubuntu2204": [
["setup", "install"],
["use", "deploy"],
["use", "undeploy"],
["setup", "uninstall"]
],
"ubuntu2004": [
["setup", "install"],
["use", "deploy"],
["use", "undeploy"],
["setup", "uninstall"]
],
"ubuntu1804": [
["setup", "install"],
["use", "deploy"],
["use", "undeploy"],
["setup", "uninstall"]
],
"centos8": [
["setup", "install"],
["use", "deploy"],
["use", "undeploy"],
["setup", "uninstall"]
],
"centos7": [
["setup", "install"],
["use", "deploy"],
["use", "undeploy"],
["setup", "uninstall"]
],
"win10-ssh": [
["use", "deploy"],
["use", "undeploy"],
],
"win10-winrm": [
["use", "deploy"],
["use", "undeploy"],
]
]
parallel_stages = [:]
for (kv in mapToList(scenarios)) {
def platform = kv[0]
def testList = kv[1]
parallel_stages[platform] = {
docker.image("${MOLECULE_DOCKER_IMAGE}").inside('-u root') {
stage("Install dependencies") {
sh "ansible-galaxy install -f -r requirements.yml"
sh "ansible-galaxy install -f -r roles/requirements.yml"
}
stage("${platform} - Create") {
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 test -s ${scenario} -p ${platform} --destroy never"
}
}
}
}
}
node {
checkout scm
withCredentials([usernamePassword(
credentialsId: 'jenkins_infra_account',
usernameVariable: 'VSPHERE_USER',
passwordVariable: 'VSPHERE_PASSWORD'
)]) {
try {
parallel(parallel_stages)
} finally {
stage("Destroy") {
sh "cd ./roles/setup && molecule destroy -s install"
}
}
}
}
@NonCPS
List<List<?>> mapToList(Map map) {
return map.collect { it ->
[it.key, it.value]
}
}