[Credentials Binding Plugin] How to specify the domain in withCredentials?

16 views
Skip to first unread message

Yuri Govorushchenko

unread,
Dec 10, 2017, 2:43:55 PM12/10/17
to Jenkins Users
Hello,

I put credentials with same ids into different domains and thus need a way to specify the domain name on invoking `withCredentials` step in my script pipeline. Is it possible?
As a workaround currently I have to find the creds manually, but this approach lacks the password masking provided by the plugin:

```
def fetchCred(String domainName, String id) {
def credentialsStore = Jenkins.instance.getExtensionList('com.cloudbees.plugins.credentials.SystemCredentialsProvider')[0].getStore()
def domain = new Domain(domainName, null, null)
def creds = credentialsStore.getCredentials(domain)
def cred = creds.find { it.id == id }
assert (cred != null)
cred
}
```

Thanks.
Reply all
Reply to author
Forward
0 new messages