powershelljenkinsparameters

Passing variable values from powershell script in Jenkins job to another job


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? :)


Solution

  • 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.