Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-34581

Please add support for Pipelines to the Powershell plugin

      I would like to use the powershell plugin from within pipelines, please add support for the pipelines to the powershell plugin.

      This is especially important as we approach Jenkins 2.0 and its move towards pipelines.

          [JENKINS-34581] Please add support for Pipelines to the Powershell plugin

          What plugins, and what versions of plugins, will need to be updated to receive this?
          Just the durable task plugin and it's dependencies?

          Marley Kudiabor added a comment - What plugins, and what versions of plugins, will need to be updated to receive this? Just the durable task plugin and it's dependencies?

          Jesse Glick added a comment -

          Pipeline: Nodes and Processes suffices.

          Jesse Glick added a comment - Pipeline: Nodes and Processes suffices.

          Brad Wehmeier added a comment -

          In my environment, executing this on a slave agent does not execute the PowerShell commands in the workspace directory. (Linux Master, Windows Slave).

          Brad Wehmeier added a comment - In my environment, executing this on a slave agent does not execute the PowerShell commands in the workspace directory. (Linux Master, Windows Slave).

          Jesse Glick added a comment -

          bradleywehmeier if you have discovered any bugs, please file separate issues (with a link to this one) containing complete, minimal steps to reproduce from scratch (and ideally also a pull request correcting the behavior).

          Jesse Glick added a comment - bradleywehmeier if you have discovered any bugs, please file separate issues (with a link to this one) containing complete, minimal steps to reproduce from scratch (and ideally also a pull request correcting the behavior).

          Gabriel Loewen added a comment - - edited

          bradleywehmeier Which directory does your command get executed in? I tested in my env, which is also a Linux Master with a Windows Slave and I see the following.  I expect the commands to be executed under C:\Program Files (x86)\Jenkins\workspace\TestWS.

          Observations

          Input:

          Get the working directory from a PowerShell step as well as a Batch script step: 

          node {
               powershell '$(pwd).Path'
               bat 'echo %cd%'
           }
          

          Output:

          [Pipeline] {
          [Pipeline] powershell
          [TestWS] Running PowerShell script
          C:\Program Files (x86)\Jenkins\workspace\TestWS
          [Pipeline] bat
          [TestWS] Running batch script
          
          C:\Program Files (x86)\Jenkins\workspace\TestWS>echo C:\Program Files (x86)\Jenkins\workspace\TestWS 
          C:\Program Files (x86)\Jenkins\workspace\TestWS
          [Pipeline] }
          [Pipeline] // node
          [Pipeline] End of Pipeline
          Finished: SUCCESS
          

           

          Can you share what your results look like?

          Gabriel Loewen added a comment - - edited bradleywehmeier Which directory does your command get executed in? I tested in my env, which is also a Linux Master with a Windows Slave and I see the following.  I expect the commands to be executed under C:\Program Files (x86)\Jenkins\workspace\TestWS. Observations Input: Get the working directory from a PowerShell step as well as a Batch script step:  node {     powershell '$(pwd).Path'     bat 'echo %cd%' } Output: [Pipeline] { [Pipeline] powershell [TestWS] Running PowerShell script C:\Program Files (x86)\Jenkins\workspace\TestWS [Pipeline] bat [TestWS] Running batch script C:\Program Files (x86)\Jenkins\workspace\TestWS>echo C:\Program Files (x86)\Jenkins\workspace\TestWS C:\Program Files (x86)\Jenkins\workspace\TestWS [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline Finished: SUCCESS   Can you share what your results look like?

          Brad Wehmeier added a comment -

          gabloe, I determined the difference was because it was loading the PowerShell Profile for the user the build agent was executing as. I'll spin this off to another issue at this point (following Jesse's guidance). It will probably be an improvement to optionally set the -NoProfile flag when calling the PowerShell executable.

          Brad Wehmeier added a comment - gabloe , I determined the difference was because it was loading the PowerShell Profile for the user the build agent was executing as. I'll spin this off to another issue at this point (following Jesse's guidance). It will probably be an improvement to optionally set the -NoProfile  flag when calling the PowerShell executable.

          Bharat Bhatia added a comment -

          gabloparm I am using Write-Host in my powershell script but dont see any output in console. Do you know if there is any other way to produce console output.

          Bharat Bhatia added a comment - gabloparm I am using Write-Host in my powershell script but dont see any output in console. Do you know if there is any other way to produce console output.

          Write-Host does not produce any output that can be consumed (e.g. written to the log). You can simply replace all of your calls to Write-Host with calls to Write-Output.

          Gabriel Loewen added a comment - Write-Host does not produce any output that can be consumed (e.g. written to the log). You can simply replace all of your calls to Write-Host with calls to Write-Output.

          Gabriel Loewen added a comment - Here's a few things to read to understand why this is the behavior of Write-Host: http://www.jsnover.com/blog/2013/12/07/write-host-considered-harmful/ http://m.windowsitpro.com/windows/write-output-or-write-host-powershell

          gabloe Running powershell in the Jenkins Pipeline is hardcoded to use no profile. The powershell plugin defaults to the opposite. Can this be made configurable?

          sebastian slutzky added a comment - gabloe Running powershell in the Jenkins Pipeline is hardcoded to use no profile . The powershell plugin defaults to the opposite. Can this be made configurable?

            gabloe Gabriel Loewen
            stuartwhelan Stuart Whelan
            Votes:
            40 Vote for this issue
            Watchers:
            51 Start watching this issue

              Created:
              Updated:
              Resolved: