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

[PATCH] Powershell improvements

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      The attached patch fixes two issues with the powershell plugin:

      • The build now fails when the script has parse errors, which it the current version doesn't do. (Because powershell.exe doesn't exits with 0 on parse errors.)
      • It avoids ExecutionPolicy errors with the default ExecutionPolicy in place.

      The changes do mean it depends om PowerShell v2, I assume (but didn't test) it will fail with PowerShell v1. But I doubt anyone considers this an issue.

      I also made the plugin depend on Jenkins 1.450 because as is it didn't build with JDK 7.

        Attachments

          Activity

          Hide
          hmagnanao Hector Magnanao added a comment - - edited

          Can some describe how to apply this patch to the powershell plugin error for executionpolicy problems ? I don't see these 2 files under my Jenkins home directory. And does this patch work for Powershell 3.0 ?

          Show
          hmagnanao Hector Magnanao added a comment - - edited Can some describe how to apply this patch to the powershell plugin error for executionpolicy problems ? I don't see these 2 files under my Jenkins home directory. And does this patch work for Powershell 3.0 ?
          Hide
          saadi60pk Muhammad Saad Shahid Usmani added a comment - - edited

          Can you please guide me how to apply this patch? I am using Jenkins ver. 1.591 on windows as Windows native package.

          I am new to jenkins if you can guide me.

          I don't see these 2 files under my Jenkins home directory.

          Where I can find the following file in Jenkins build directory?

          src/main/java/hudson/plugins/powershell/PowerShell.java

          Show
          saadi60pk Muhammad Saad Shahid Usmani added a comment - - edited Can you please guide me how to apply this patch? I am using Jenkins ver. 1.591 on windows as Windows native package. I am new to jenkins if you can guide me. I don't see these 2 files under my Jenkins home directory. Where I can find the following file in Jenkins build directory? src/main/java/hudson/plugins/powershell/PowerShell.java
          Hide
          avee Arjan Veenstra added a comment - - edited

          You don't need to apply this patch, it's already in the latest release of the plugin.

          Show
          avee Arjan Veenstra added a comment - - edited You don't need to apply this patch, it's already in the latest release of the plugin.
          Hide
          tpbradt Tim Bradt added a comment -

          I just installed the plugin today (v1.2) and my job did not fail even though the Powershell errored:

          Started by user anonymous
          [EnvInject] - Loading node environment variables.
          Building on master in workspace C:\SPE\Jenkins\jobs\Test1\workspace
          [EnvInject] - Injecting environment variables from a build step.
          [EnvInject] - Injecting as environment variables the properties file path 'C:/SPE/Jenkins/DailyBuild/buildtime.properties'
          [EnvInject] - Variables injected successfully.
          [workspace] $ cmd /c call C:\Users\SPESER~1\AppData\Local\Temp\hudson868747164412287880.bat

          C:\SPE\Jenkins\jobs\Test1\workspace>rem echo BUILDTIME=1027 > C:\SPE\Jenkins\DailyBuild\buildtime.properties

          C:\SPE\Jenkins\jobs\Test1\workspace>exit 0
          [workspace] $ powershell.exe "& 'C:\Users\SPESER~1\AppData\Local\Temp\hudson7972185748419603015.ps1'"
          out-file : Could not find a part of the path 'C:\SPE\Jenkins\jobs\Test1\workspace%SE_R_MASTER%\buildtime.properties'.
          At C:\Users\speservice\AppData\Local\Temp\hudson7972185748419603015.ps1:2 char:1
          + Write-Output "BUILDTIME=$time" > %SE_R_MASTER%\buildtime.properties
          + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo : OpenError: ( [Out-File], DirectoryNotFoundException
          + FullyQualifiedErrorId : FileOpenFailure,Microsoft.PowerShell.Commands.OutFileCommand

          Finished: SUCCESS

          I don't like being locked in to being path relative to workspace (the windows batch command doesn't do this). Yes, I have already adjusted my path, but my primary issue is having the false positive. That makes it unusable in a production environment.

          Show
          tpbradt Tim Bradt added a comment - I just installed the plugin today (v1.2) and my job did not fail even though the Powershell errored: Started by user anonymous [EnvInject] - Loading node environment variables. Building on master in workspace C:\SPE\Jenkins\jobs\Test1\workspace [EnvInject] - Injecting environment variables from a build step. [EnvInject] - Injecting as environment variables the properties file path 'C:/SPE/Jenkins/DailyBuild/buildtime.properties' [EnvInject] - Variables injected successfully. [workspace] $ cmd /c call C:\Users\SPESER~1\AppData\Local\Temp\hudson868747164412287880.bat C:\SPE\Jenkins\jobs\Test1\workspace>rem echo BUILDTIME=1027 > C:\SPE\Jenkins\DailyBuild\buildtime.properties C:\SPE\Jenkins\jobs\Test1\workspace>exit 0 [workspace] $ powershell.exe "& 'C:\Users\SPESER~1\AppData\Local\Temp\hudson7972185748419603015.ps1'" out-file : Could not find a part of the path 'C:\SPE\Jenkins\jobs\Test1\workspace%SE_R_MASTER%\buildtime.properties'. At C:\Users\speservice\AppData\Local\Temp\hudson7972185748419603015.ps1:2 char:1 + Write-Output "BUILDTIME=$time" > %SE_R_MASTER%\buildtime.properties + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : OpenError: ( [Out-File] , DirectoryNotFoundException + FullyQualifiedErrorId : FileOpenFailure,Microsoft.PowerShell.Commands.OutFileCommand Finished: SUCCESS I don't like being locked in to being path relative to workspace (the windows batch command doesn't do this). Yes, I have already adjusted my path, but my primary issue is having the false positive. That makes it unusable in a production environment.
          Hide
          orrc Christopher Orr added a comment -

          Just for info: note that this issue has been fixed in GitHub, but a new release has not yet been made which includes this fix.

          The current version, 1.2, is from 2009, so does not include this fix.

          Show
          orrc Christopher Orr added a comment - Just for info: note that this issue has been fixed in GitHub, but a new release has not yet been made which includes this fix. The current version, 1.2, is from 2009, so does not include this fix.

            People

            • Assignee:
              Unassigned
              Reporter:
              avee Arjan Veenstra
            • Votes:
              3 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: