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

PowerShell plugin - Write-Debug shows blank lines in the console for carriage returns

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Minor Minor
    • powershell-plugin
    • None
    • Windows Server 2012 R2
      PowerShell 5.1
      Jenkins 2.135
      PowerShell Plugin 1.3

      Using a Windows PowerShell build step (PowerShell Plugin) and calling Write-Debug with a string that has carriage returns (0x13) results in Jenkins console output that is double-spaced. This does not happen with Out-Host, however.

      In Windows, the default line-ending characters ([Environment]::NewLine) are 0x13 0x10, so all Write-Debug calls that specify a multi-line message end up double-spaced.  It is just a cosmetic issue, but it is sloppy-looking, and harder to read, especially when dumping an object with many properties to Write-Debug.

      Example:  Put this in a Windows PowerShell build step and run the job:

      $s1 = "s1Line1" + [Environment]::NewLine + "s1Line2"
      $s2 = "s2Line1`ns2Line2"
      "Out-Host:" | Out-Host
      $s1 | Out-Host
      $s2 | Out-Host
      "Write-Debug:" | Out-Host
      Write-Debug $s1
      Write-Debug $s2

      The Jenkins console output looks like this:

      Out-Host:
      s1Line1
      s1Line2
      s2Line1
      s2Line2
      Write-Debug:
      DEBUG: s1Line1

      s1Line2
      DEBUG: s2Line1
      s2Line2

      note the blank line after "DEBUG: s1Line1", but not after "DEBUG: s2Line1"}}{{

            Unassigned Unassigned
            langtonben Ben Langton
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: