forked from electric-cloud-community/DSL-Samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreateConfiguration.groovy
45 lines (42 loc) · 1.29 KB
/
createConfiguration.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
/*
This is a sample to create a Configuration for a plugin lioke EC-ServiceNow
*/
def conf="snow-config"
def proj="/plugins/EC-ServiceNow/project"
def uName='myUser'
def pwd='mypassword' // or you would better grab it from an extertnal source
// Create a Transient credential
def Cred = new RuntimeCredentialImpl()
Cred.name = conf
Cred.userName = uName
Cred.password = pwd
def Creds=[Cred]
// Call the config creation procedure
// if it does not already exists
// by checking if the config property (name may be different in different plugin)
if (! getProperty("$proj/ServiceNow_cfgs/$conf")) {
runProcedure(
projectName : proj,
procedureName : "CreateConfiguration",
actualParameter : [
config: conf, // required
host: "http://serviceNow", // required
credential: conf, // Credential has the same name than the config
http_proxy: "",
proxy_credential: "",
],
credential: Creds
)
} else {
// overwrite the credential
credential(
projectName: proj,
userNane: uName
password: pwd
credentialName: conf
)
// overtrite properties
setProperty("$proj/ServiceNow_cfgs/$conf/host": value: "http://myNewHost"
setProperty("$proj/ServiceNow_cfgs/$conf/http_proxy": value: "http://myProxy"
//.....
}