1

I have two Jenkins Jobs JOB A and JOB B. JOB A is responsible to trigger JOB B. JOB A has a Post-build Action and I am assigning parameter value and that is JSON like below:

Im JOB B I want to use that String parameter and I want to create a JSON file and want to save that im JOB B's workspace.

I used Groovy but am not sure how to access my param Sample.

2
  • 1
    Is your problem that JOB B doesn't get the Sample parameter or that you don't know how to access it in Groovy? There's no need for Groovy, however: A simple echo %Sample% > %WORKSPACE%\Sample.json in an Execute Windows batch command build step (or a shell-equivalent) in JOB B does the trick. Commented Aug 4, 2021 at 23:05
  • looks fine you are correct not need of Groovy script , only windows batch do work ..Thanks Commented Aug 10, 2021 at 17:11

1 Answer 1

1

There's no need for Groovy. A simple:

echo %Sample% > %WORKSPACE%\Sample.json

in an Execute Windows batch command build step (or a shell-equivalent) in JOB B does the trick, too.

See Jenkins Set Environment Variables:

Environment Variable Description
WORKSPACE The absolute path of the workspace.
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.