0

In a powershell build step in job1 in Jenkins I am filtering/calculating values that I want to use in Jenkins job2, also in a powershell build step. How can I do this? It is a Freestyle project.

I have tried using "This project is parameterized"/"Predefined parameters" giving the same names of the parameters in each job, with no luck.

I have also tried passing the parameters with $env:variable1, ${env:variable1}, $($env:variable1) with no luck.

I have also tried creating a global parameter in Jenkins and assigning/accessing it with no luck.

Ideas? :)

2
  • 1
    Is the first job calling the second one? If so you will have to read the relevant value for the first PS execution into the pipeline and pass it to the second job via the build step. Commented Jul 4 at 23:16
  • Yes, the first job is calling the second one. I´m sorry I forgot to mention that it is a Freestyle project, so I can't use pipeline. Commented Jul 7 at 6:58

1 Answer 1

1

Let me cite this answer to the question Passing data between build steps in Jenkins which I guess still holds true:

None of:

  • String Parameter of a Parameterized Build
  • pre-build Inject environment variables to the build process
  • in-build step Inject environment variables

works (as of v1.656). You are able to read each of them, of course, but new values that are assigned to them are not available in subsequent build steps.

Hence, Dominik's answer and handling via file like in Destroyica's answer are the only options so far.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for that answer. I have it working in pipelines as suggested, but I had to go with a file-solution similar to your suggestion, since I'm using a Freestyle project in this case. I went with a xml-file, and store in on a network-location so that it is easier at access it from different agents.

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.