Created
July 3, 2020 03:47
-
-
Save marcosborges/5f3ebacd76478d16eb68d6f87d783bf7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import jenkins.model.Jenkins; | |
import com.cloudbees.hudson.plugins.folder.Folder | |
import com.cloudbees.plugins.credentials.Credentials | |
import com.cloudbees.plugins.credentials.CredentialsProvider | |
def folderName = "folder/subfolder/subsubfolder" | |
def credentialId = "credential-id" | |
def folder = Jenkins.getInstance().getAllItems(Folder.class).find({ it -> it.getFullName().contains(folderName) }) | |
def credInFolder = CredentialsProvider.lookupCredentials(Credentials.class, folder).find({ it -> it.id == credentialId && !it.scope }) | |
println "FOLDER ${credInFolder?.id}" | |
def credGlobal = CredentialsProvider.lookupCredentials(Credentials.class).find({ it -> it.id == credentialId }) | |
println "GLOBAL ${credGlobal?.id}" | |
return true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment