I am developing an app which consumes credentials/secrets from Jenkins vault. I am getting it via withCredntials in the groovy script. After getting the credentials I need to update the same in my application properties file before the jar generation.
I have tried to achieve this by some of the tips from google search, but nothing worked. I have used push commands to get this done. Please help me to sort out this issue.
withCredentials([usernamePassword(credentialsId: '<vault key>',
usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
// push logic
}
First Approach:
touch myapp.properties
git config --global db.cred= "${USER}
git add myapp.properties
git commit -m 'file added'
git push central mybranch
o/p - no results, no errors
Second approach:
def newFile=new File("myapp.properties")
newFile.write("db.creds..")
git add myapp.properties
git commit -m 'file added'
git push central mybranch
o/p: Error - Scripts not permitted to use java.io.File.java.lang.String
Jenkins build is not triggering after the push statement