-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparams.groovy
106 lines (76 loc) · 3.39 KB
/
params.groovy
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
// String Parameter: repoPath
// Description: Format: <UserName/Repository>
// def repoPath = "Lifailon/usup"
// Active Choices Reactive Parameter: repoBranch
// Description: Select branch
// Referenced parameters: repoPath
import groovy.json.JsonSlurper
def url = "https://api.github.com/repos/${repoPath}/branches"
def URL = new URL(url)
def connection = URL.openConnection()
connection.requestMethod = 'GET'
connection.setRequestProperty("Accept", "application/vnd.github.v3+json")
def response = connection.inputStream.text
def json = new JsonSlurper().parseText(response)
def branches = json.collect { it.name }
return branches as List
// Active Choices Reactive Parameter: fileName
// Description: Select configuration file (supfile in yml/yaml format)
// Referenced parameters: repoPath,repoBranch
import groovy.json.JsonSlurper
def url = "https://api.github.com/repos/${repoPath}/git/trees/${repoBranch}?recursive=1"
def URL = new URL(url)
def connection = URL.openConnection()
connection.requestMethod = 'GET'
def response = connection.inputStream.text
def json = new JsonSlurper().parseText(response)
def yamlFiles = json.tree.findAll { it.path.endsWith('.yml') || it.path.endsWith('.yaml') }.collect { it.path }
return yamlFiles as List
// Active Choices Reactive Parameter: network
// Description: Set host list (each host on a new line) for Network: local-list
// Referenced parameters: repoPath,repoBranch,fileName
import org.yaml.snakeyaml.Yaml
def url = "https://raw.githubusercontent.com/${repoPath}/refs/heads/${repoBranch}/${fileName}"
def supfile = new URL(url).getText()
def yaml = new Yaml()
def data = yaml.load(supfile)
return data.networks.keySet() as List
// Multi-line String Parameter: localHostList
// Description: Set host list (each host on a new line in the format USER@IP:PORT) for network group: local-host-list
// def repoPath = "Lifailon/usup"
// Active Choices Reactive Parameter: command
// Description: Select command for run
// Referenced parameters: repoPath,repoBranch,fileName
import org.yaml.snakeyaml.Yaml
def url = "https://raw.githubusercontent.com/${repoPath}/refs/heads/${repoBranch}/${fileName}"
def supfile = new URL(url).getText()
def yaml = new Yaml()
def data = yaml.load(supfile)
return data.commands.keySet() as List
// Active Choices Reactive Parameter: target
// Description: Select target (groups of commands) for run or using null for command run
// Referenced parameters: repoPath,repoBranch,fileName
import org.yaml.snakeyaml.Yaml
def url = "https://raw.githubusercontent.com/${repoPath}/refs/heads/${repoBranch}/${fileName}"
def supfile = new URL(url).getText()
def yaml = new Yaml()
def data = yaml.load(supfile)
def targetsList = data.targets.keySet() as List
targetsList.add(0, null)
return targetsList
// Active Choices Reactive Reference Parameter: env
// Description: Environment variables list
// Choice Type: Bullet items list
// Referenced parameters: repoPath,repoBranch,fileName
import org.yaml.snakeyaml.Yaml
def url = "https://raw.githubusercontent.com/${repoPath}/refs/heads/${repoBranch}/${fileName}"
def supfile = new URL(url).getText()
def yaml = new Yaml()
def data = yaml.load(supfile)
def keyValueList = []
for (entry in data.env.entrySet()) {
keyValueList.add("${entry.key}=${entry.value}")
}
return keyValueList as List
// Multi-line String Parameter: envVars
// Description: Change variable values in the format KEY=VALUE (each variable on a new line)