I have found a way to access the credentials store in Jenkins:
def getPassword = { username ->
def creds = com.cloudbees.plugins.credentials.CredentialsPr
The official solution n the jenkins wiki
Printing a list of all the credentials in the system and their IDs.
def creds = com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials(
com.cloudbees.plugins.credentials.Credentials.class,
Jenkins.instance,
null,
null
);
for (c in creds) {
println(c.id + ": " + c.description)
}