-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile-input-choice
59 lines (55 loc) · 1.74 KB
/
Jenkinsfile-input-choice
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
def userInput(){
def userInput
while(true){
userInput=input(
id: "USERINPUT",
message: "Please provide the following input: ",
parameters: [
string(
name:"USERNAME",
defaultValue:"",
description:"Please provide a username: "
),
choice(
name:"ACTION",
description:"Please select an action: ",
choices:[
"ADD",
"DELETE",
"MODIFY"
]
)
]
)
if (userInput["USERNAME"].trim()){
break
} else {
echo "The username can't be empty. Please re-input a username."
}
}
return userInput
}
def printInput(inputValues){
echo "******** Printing input ********"
/*
echo "The input username is ${inputValues["USERNAME"]}."
echo "The selected action is ${inputValues["ACTION"]}."
if (inputValues["ACTION"] == "ADD") {
echo "The user ${inputValues["USERNAME"]} will be ${inputValues["ACTION"]}. "
} else if (inputValues["ACTION"] == "DELETE") {
echo "The user ${inputValues["USERNAME"]} will be ${inputValues["ACTION"]}. "
} else if (inputValues["ACTION"] == "MODIFY") {
echo "The user ${inputValues["USERNAME"]} will be ${inputValues["ACTION"]}. "
}
*/
echo "The user ${inputValues["USERNAME"]} will be ${inputValues["ACTION"]}. "
echo "******** Ending Printing ********"
}
node {
stage("User Input"){
script{
def inputValues=userInput()
printInput(inputValues)
}
}
}