Skip to content

Instantly share code, notes, and snippets.

Created March 28, 2016 06:16
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Check credentials by name if they already exist in Jenkins
import com.cloudbees.plugins.credentials.*
import com.cloudbees.plugins.credentials.common.*
def credentials_for_username(String username) {
def username_matcher = CredentialsMatchers.withUsername(username)
def available_credentials =
return CredentialsMatchers.firstOrNull(available_credentials, username_matcher)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment