I have a Java project that builds on Jenkins. This code needs a Secret file (.pem format) to run. I can't save the file in the Java project itself (security reasons).
The file format is key_v2-XXXXX.pem and contents are
-----BEGIN PRIVATE KEY-----
XXX
XXXX
-----END PRIVATE KEY-----
Currently, the Java code is accessing the Secret file present in the Local. So the local build is fine. But when this code is executed on Jenkins, the build fails because it can't find the local file or the file is not accessible to Jenkins.
I've added the Secret File as a Global Credential (unrestricted) in Jenkins. (Reference - https://jenkins.io/doc/book/using/using-credentials/)
I need to find a way for the Java code to access this Secret file(stored in Jenkins) while running the Jenkins build.
Or Is there any other way to handle this situation?