From 048fe0b4d7fdd4d11d1d0fdcbc154b31089b3ac1 Mon Sep 17 00:00:00 2001 From: Jessica Wagantall Date: Wed, 10 Jan 2018 12:22:25 -0800 Subject: [PATCH] Add script to print all creds in Jenkins Add groovy script to run in the script console that will display all credentials registered in Jenkins in an Id : Password format. Change-Id: I81d74a72a1bb5558c7230a6da7a5de055de809c9 Signed-off-by: Jessica Wagantall --- jenkins-admin/get_all_creds.groovy | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 jenkins-admin/get_all_creds.groovy diff --git a/jenkins-admin/get_all_creds.groovy b/jenkins-admin/get_all_creds.groovy new file mode 100644 index 00000000..13a5b2a9 --- /dev/null +++ b/jenkins-admin/get_all_creds.groovy @@ -0,0 +1,25 @@ +/***************** +* Extracts all registered credentials and passwords +* +* Jenkins credentials are encrypted and passwords cannot be retrived easily. +* Run this script to get all credentials pairs in an "Id : Password" format. +* Note: This script will not display information for SSH and Certificate +* credential types. +* +*****************/ + +import com.cloudbees.plugins.credentials.* + +println "Printing all the credentials and passwords..." +def creds = com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials( + com.cloudbees.plugins.credentials.common.StandardUsernameCredentials.class, + Jenkins.instance, + null, + null +); + +for (c in creds) { + try { + println(c.id + " : " + c.password ) + } catch (MissingPropertyException) {} +} -- 2.16.6