nova_rubo
nova_rubo

Reputation: 49

fetching details from jenkins workspace to build another step in the same jenkins job

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

Upvotes: 1

Views: 271

Answers (1)

Travenin
Travenin

Reputation: 1590

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"

Upvotes: 0

Related Questions