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

Powershell step in pipeline job outputs UTF-8 BOM

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • Jenkins 2.60.2
      Windows Server 2012 R2
      PSVersion 5.1.15063.502

      Plugins:
      Powershell 1.3
      Pipeline: Build Step 2.5.1
      Pipeline 2.5

      Powershell step in pipeline outputs UTF-8 BOM characters with Powershell output.

      [workspace] Running PowerShell script
      Hello
      

      If I run the same command (Write-Host "Hello") in a usual build job as a Powershell step it outputs normal output:

      [workspace] $ powershell.exe -NonInteractive -ExecutionPolicy ByPass "& 'C:\Users\VALERY~1.ZAB\AppData\Local\Temp\jenkins2440165524934484537.ps1'"
      Hello
      Finished: SUCCESS
      

      Here's my powershell step code:

      powershell 'Write-Host "Hello"'
      

          [JENKINS-46496] Powershell step in pipeline job outputs UTF-8 BOM

          Valeriy Zabawski created issue -
          Andrew Bayer made changes -
          Component/s New: durable-task-plugin [ 18622 ]
          Component/s New: workflow-durable-task-step-plugin [ 21715 ]
          Component/s Original: pipeline-stage-step-plugin [ 21709 ]
          Jesse Glick made changes -
          Remote Link New: This issue links to "Page (Jenkins Wiki)" [ 18024 ]
          Gabriel Loewen made changes -
          Assignee New: Gabriel Loewen [ gabloe ]
          Gabriel Loewen made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]
          Gabriel Loewen made changes -
          Status Original: In Progress [ 3 ] New: In Review [ 10005 ]
          Jakub Michalec made changes -
          Comment [ {code:java}
          C:\CI\Jenkins\...@tmp\durable-f7d18e60\powershellWrapper.ps1 : You
          cannot call a method on a null-valued expression.
          At C:\CI\Jenkins\...@tmp\durable-f7d18e60\powershellHelper.ps1:30
          char:7
          + & $MainScript *>&1 | Out-FileNoBom -FilePath $LogFile; $LastExi ...
          + ~~~~~~~~~~~~~~~~~~
              + CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
              + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,powershellWrapper.ps1{code}
           

          I get above error when passing to ps script parameter with space eq 95f9a9463de59ce3f9f5807643ab32feaffa30ad      refs/heads/master

          (passed to -commitHash)
          {code:java}
          powershell(script: """
          . .\\scripts\\artifactsPicker.ps1 -storageAccountName $storageAccount `
          -branchName $pipelineParams.branchName `
          -packageParameters "$packageParameters" `
          -buildNewPackage $pipelineParams.buildNewPkg `
          -commitHash "$getLastPackageHash" `
          """){code}
           

          Script was working o 1.15, failure since I update to 1.17

            ]
          Sam Van Oort made changes -
          Resolution New: Fixed [ 1 ]
          Status Original: In Review [ 10005 ] New: Closed [ 6 ]

            gabloe Gabriel Loewen
            dziki_jam Valeriy Zabawski
            Votes:
            6 Vote for this issue
            Watchers:
            16 Start watching this issue

              Created:
              Updated:
              Resolved: