withCredentials(bindings: [
certificate(aliasVariable: 'alias', credentialsId: 'myId', keystoreVariable: 'keystoreName', passwordVariable: 'keyPassword')
]) {
def keystoreFormat = "PKCS12"
print "test : " + Secret(
try {
try {
p12file = new FileInputStream(keystoreName)
} catch (error) {
println "File p12 input stream error :"
println error.toString()
println error.getMessage()
print error.printStackTrace()
throw error
}
println "P12file opened"
try {
keystore = KeyStore.getInstance(keystoreFormat)
keystore.load(p12file, keyPassword.toCharArray())
} catch (error) {
println "Loading KeyStore :"
println error.toString()
println error.getMessage()
print error.printStackTrace()
throw error
}
def key = keystore.getKey(alias, keyPassword.toCharArray())
println "-----BEGIN PRIVATE KEY-----"
println key.getEncoded().encodeBase64()
println "-----END PRIVATE KEY-----"
} catch(error) {
print "Error Reading p12 : "
println error.toString()
println error.getMessage()
print error.printStackTrace()
throw error
}
[Pipeline] echo java.io.FileNotFoundException: **** (No such file or directory) [Pipeline] echo **** (No such file or directory)
I could verify that the file exists, but I can't open it.
Any idea will be greatly appreciate.
Many thanks