0

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

asder
  • 27
  • 8
  • Please share your code and the error/problem. Otherwise it's not clear what issue do you have – daggett Jun 24 '19 at 06:46
  • 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 – asder Jun 25 '19 at 19:38
  • Please put all this into your question. It's impossible to read code in comments ) – daggett Jun 25 '19 at 21:29
  • Done. please check – asder Jun 27 '19 at 19:17
  • Your question already answered: https://stackoverflow.com/questions/38276341/jenkins-ci-pipeline-scripts-not-permitted-to-use-method-groovy-lang-groovyobject – daggett Jun 27 '19 at 20:43

0 Answers0