1

I have a jenkins job that generates properties file in the workspace. I want to know if it is possible read the property file from workspace and then pass it as a argument for a program in the next build step of the same job??

I tried reading to read the file via a groovy script echo env.WORKSPACE 64
String fileContents = new File("${env.WORKSPACE}"/key_generate.properties").getText('UTF-8')

but i get the below error java.io.IOException: Cannot run program "groovy" (in C:\xyz\directory path)

I am using a windows node

1 Answer 1

0

You cannot use java.io.File because it is prohibited for security reasons, for example. Instead you can use Jenkins step readFile to read a file from workspace. Try this in your code:

String fileContents = readFile "${env.WORKSPACE}/key_generate.properties" 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.