Process the powershell result on the jenkins server

14 views
Skip to first unread message

Michael Renner

unread,
Feb 26, 2020, 9:41:58 AM2/26/20
to Jenkins Users
Moin,


I am new to this group but I have been using jenkins for many years.

Now I have a request that I don't know what to do next. My jenkins server (Linux) connect to an agent on a Windows server and calls a power shell script. The script reports a result back, for example, "day", "night", "red" or "blue". This should now be processed on the Jenkins server (a bash script). But how? An other build step would run at the Windows server again, a post build action won't start external processes like bash scripts. I could create a second job that runs on the Jenkins master itself. But how do I get the results of the Power Shell script?

Grateful for hints

Slide

unread,
Feb 26, 2020, 9:49:32 AM2/26/20
to Jenkins User Mailing List
Hi Michael,

It sounds like you are using a Free Style job, is that correct? Something like this is pretty easy to do in pipeline, but can be difficult in Free Style jobs. One way to do it is to write the value to a properties file in the powershell script and then use the EnvInject plugin to inject the value(s) from the properties file into the environment of the job using the 'Environment Properties File Path' item. Look for the  'Inject environment variables for your job' build step when setting up the job.

Hopefully that will at least get you started down the right path.

Regards,

Alex


--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/7604abe1-01fd-4f07-94c9-0352318ebba7%40googlegroups.com.


--

Eric Pyle

unread,
Feb 26, 2020, 1:36:51 PM2/26/20
to jenkins...@googlegroups.com
Extending on Slide's idea, you can write the result to a file in the workspace and save that file as a build artifact. Then in the downstream job that runs on the master you can retrieve the artifact from the upstream job (copy artifacts from other job) and read the value in your bash script. Or similarly, if you write the file in the upstream job as a properties file "VARNAME=$value" then you can use that file to set a parameter to pass to the downstream job (parameters from properties file).

Eric
--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/7604abe1-01fd-4f07-94c9-0352318ebba7%40googlegroups.com.

-- 
Eric Pyle
Siemens Digital Industries Software
Simulation and Test Solutions, Product Development
eric...@siemens.com
https://www.sw.siemens.com/

Michael Renner

unread,
Feb 27, 2020, 1:09:20 PM2/27/20
to Jenkins Users

Thanks Alex und Eric you for the answers. I had considered writing my first pipeline job, but then I stayed on the familiar path. With the help of the Copy Artifact plugin, I copy the results and parse that in bash.

Regards, Micha


Am Mittwoch, 26. Februar 2020 19:36:51 UTC+1 schrieb Eric Pyle:
Extending on Slide's idea, you can write the result to a file in the workspace and save that file as a build artifact. Then in the downstream job that runs on the master you can retrieve the artifact from the upstream job (copy artifacts from other job) and read the value in your bash script. Or similarly, if you write the file in the upstream job as a properties file "VARNAME=$value" then you can use that file to set a parameter to pass to the downstream job (parameters from properties file).

Eric

On 2/26/2020 8:26 AM, Michael Renner wrote:
Moin,


[...]

Reply all
Reply to author
Forward
0 new messages