In a jenkinsfile, the "Credentials Binding" plugin can be used with withCredentials
.
Example:
withCredentials([usernamePassword(etc)]) { ... }
What are all the credential types that can be used with withCredentials
, what are their keywords and parameters, and how do they appear in the Jenkins server "credentials" GUI?
In a jenkinsfile, the "Credentials Binding" plugin can be used with withCredentials
.
Example:
withCredentials([usernamePassword(etc)]) { ... }
What are all the credential types that can be used with withCredentials
, what are their keywords and parameters, and how do they appear in the Jenkins server "credentials" GUI?
1 Answer
Reset to default 1Plugins can add their own credential types, but these are the most commonly used built-in credential types (as of Jenkins 2.452.1):
usernamePassword( // "Username and Password" in the GUI
credentialsId: 'cred',
usernameVariable: 'user',
passwordVariable: 'pass')
sshUserPrivateKey( // "Username with private key" in the GUI
credentialsId: 'cred',
keyFileVariable: 'keyFilepath',
usernameVariable: 'user', // optional
passphraseVariable: 'pass') // optional
string( // "Secret text" in the GUI
credentialsId: 'cred',
variable: 'str')
file( // "Secret file" in the GUI
credentialsId: 'cred',
variable: 'filePath')
certificate( // "Certificate" in the GUI, for PKCS#12 certificates
credentialsId: 'cred',
keystoreVariable: 'keystore',
aliasVariable: 'alias', // optional
passwordVariable: 'pass') // optional
You can find many more types in the documentation for the credentials binding plugin, but many of those listed do not seem to (by default) have any way of creating that type of credential via the GUI. It may be that they require plugins.