Created
February 11, 2022 22:37
-
-
Save DerPauli/496171862b5c6b5d9024c933b58e6b9d to your computer and use it in GitHub Desktop.
Print Jenkins credentials from script console
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 java.nio.charset.StandardCharsets; | |
def creds = com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials( | |
com.cloudbees.plugins.credentials.Credentials.class | |
) | |
for (c in creds) { | |
println(c.id) | |
if (c.properties.description) { | |
println(" description: " + c.description) | |
} | |
if (c.properties.username) { | |
println(" username: " + c.username) | |
} | |
if (c.properties.password) { | |
println(" password: " + c.password) | |
} | |
if (c.properties.passphrase) { | |
println(" passphrase: " + c.passphrase) | |
} | |
if (c.properties.secret) { | |
println(" secret: " + c.secret) | |
} | |
if (c.properties.secretBytes) { | |
println(" secretBytes: ") | |
println("\n" + new String(c.secretBytes.getPlainData(), StandardCharsets.UTF_8)) | |
println("") | |
} | |
if (c.properties.privateKeySource) { | |
println(" privateKey: " + c.getPrivateKey()) | |
} | |
if (c.properties.apiToken) { | |
println(" apiToken: " + c.apiToken) | |
} | |
if (c.properties.token) { | |
println(" token: " + c.token) | |
} | |
println("") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment