Created
February 7, 2024 09:35
-
-
Save VMuliadi/32e6eace6d7a1f3aad66758e530e8a03 to your computer and use it in GitHub Desktop.
decrypt credentials files in jenkins
This file contains 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 com.cloudbees.plugins.credentials.*; | |
import com.cloudbees.plugins.credentials.domains.Domain; | |
import org.jenkinsci.plugins.plaincredentials.impl.FileCredentialsImpl; | |
def jenkins_credentials_id = "my-jenkins-credentials-file-id" | |
SystemCredentialsProvider.getInstance().getCredentials().stream(). | |
filter { cred -> cred instanceof FileCredentialsImpl }. | |
map { fileCred -> (FileCredentialsImpl) fileCred }. | |
filter { fileCred -> jenkins_credentials_id.equals( fileCred.id ) }. | |
forEach { fileCred -> | |
String s = new String( fileCred.getSecretBytes().getPlainData() ) | |
println(s) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment