-
Notifications
You must be signed in to change notification settings - Fork 92
Expand file tree
/
Copy pathgitparam.groovy
More file actions
59 lines (46 loc) · 1.59 KB
/
gitparam.groovy
File metadata and controls
59 lines (46 loc) · 1.59 KB
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 getbranches = "git ls-remote -h -t https://github.com/quickfixsoln/springexample.git".execute()
def branches = []
def b1 = []
getbranches.text.eachLine {branches.add(it)}
for(i in branches)
b1.add(i.split()[1].replaceAll('\\^\\{\\}', '').replaceAll('refs/tags/', '').replaceAll('refs/heads/', ''))
b1 = b1.unique()
return b1
def getbranches = "git ls-remote -h -t https://github.com/quickfixsoln/springexample.git".execute()
def branches = []
def b1 = []
getbranches.text.eachLine {branches.add(it)}
for(i in branches)
b1.add(i.split()[1].replaceAll('\\^\\{\\}', '').replaceAll('refs/tags/', '').replaceAll('refs/heads/', ''))
b1 = b1.unique()
return b1
import groovy.json.JsonSlurperClassic
import jenkins.model.Jenkins
creds = getCredentials()
def getCredentials() {
def creds = com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials(
com.cloudbees.plugins.credentials.common.StandardUsernameCredentials.class,
Jenkins.instance,
null,
null)
for (c in creds) {
if (c.id == "CREDENTIALS_ID") {
user = c.username
pass = c.password
}
}
def credentials = "${user}:${pass}"
return credentials.toString()
}
sn = 'git ls-remote -h -t https://'+creds+'@bitbucket.org/devopsmar12019/'+servicename+'.git'
def getbranches = sn.execute()
def branches = []
def b1 = []
getbranches.text.eachLine {branches.add(it)}
for(i in branches)
b1.add(i.split()[1].replaceAll('\\^\\{\\}', '').replaceAll('refs/tags/', '').replaceAll('refs/heads/', ''))
b1 = b1.unique()
return b1
--------------
Active Choices Parameter
Active Choices Reactive Parameter