forked from electric-cloud-community/DSL-Samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWorkingWithCredentials.groovy
56 lines (44 loc) · 1.5 KB
/
WorkingWithCredentials.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
project 'Credential Examples', {
credential 'user1', userName: 'user1', password: "user1password", passwordRecoveryAllowed = true
credential 'user2', userName: 'user2', password: "user2password", passwordRecoveryAllowed = true
procedure 'Get Credentials with javascript', {
formalParameter "Credential", required: true, defaultValue: "user1"
step 'Get Credentials', command : '''\
echo USER: $[/javascript
var creds = {
credentialName : "user1",
jobStepId: myJobStep.jobStepId
}
api.getFullCredential(creds).credential.userName
]
echo PASS: $[/javascript
var creds = {
credentialName : "user1",
jobStepId: myJobStep.jobStepId
}
api.getFullCredential(creds).credential.password
]
'''.stripIndent(),{
attachCredential(
credentialName: 'user1',
)
} // step
step 'Get Credentials with ectool', command : '''\
ectool getFullCredential user1 --value userName
ectool getFullCredential user1 --value password
'''.stripIndent(),{
attachCredential(
credentialName: 'user1',
)
} // step
step "Dynamic credentials with createJobStep", shell: 'ec-perl', command: '''\
use strict;
use ElectricCommander;
$| = 1;
my $ec = new ElectricCommander();
$ec->createJobStep({
command => "ectool getFullCredential $[Credential] --value userName;ectool getFullCredential $[Credential] --value password",
});
'''.stripIndent()
} // procedure
}