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

Powershell pipeline step: Enable selecting debug/verbose streams for console output

      Consider this declarative pipeline:

      Jenkinsfile
      pipeline {
          agent any
      
          stages {
              stage('Deploy') {
                  steps {
                      powershell 'Write-Verbose \'This is the verbose stream\''
                      powershell 'Write-Information \'This is the info stream\''
                  }
              }
          }
      }
      

      The console output looks like this:

      [Pipeline] // stage
      [Pipeline] stage
      [Pipeline] { (Deploy)
      [Pipeline] powershell[microservice-helpers] Running PowerShell script
      [Pipeline] powershell[microservice-helpers] Running PowerShell script
      This is the info stream
      [Pipeline] }
      [Pipeline] // stage

      Notice that the verbose stream is not written to the console. I propose a new flag for the powershell step, which would allow user-selected streams (such as Verbose and Debug) to be output to console.

      To get these streams in powershell, it is generally only necessary to use the common parameters -Debug and -Verbose when calling the script. See this link for more information:

      https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_commonparameters?view=powershell-5.1

      Another way to trigger output of the verbose stream is to set $VerbosePreference = 'Continue' at a global level in the shell before running the actual script.
       

      See also this blog post on streams in powershell:

      https://blogs.technet.microsoft.com/heyscriptingguy/2014/03/30/understanding-streams-redirection-and-write-host-in-powershell/

       

          [JENKINS-47642] Powershell pipeline step: Enable selecting debug/verbose streams for console output

          Francis Therien created issue -
          Francis Therien made changes -
          Description Original: Consider this declarative pipeline:

          {{pipeline \{}}
          {{    agent \{label 'MachineCompileDashboard'}}}

          {{    stages \{}}
          {{        stage('Deploy') \{}}
          {{            steps \{}}
          {{                powershell 'Write-Verbose \'This is the verbose stream\''}}
          {{                powershell 'Write-Information \'This is the info stream\''}}
          {{            }}}
          {{        }}}
          {{    }}}
          {{}}}

          The console output looks like this:
          {color:#9a9999}[Pipeline] // stage{color}{color:#9a9999}[Pipeline] stage{color}{color:#9a9999}[Pipeline] \{ (Deploy){color}{color:#9a9999}[Pipeline] powershell{color}[microservice-helpers] Running PowerShell script{color:#9a9999}[Pipeline] powershell{color}[microservice-helpers] Running PowerShell script
          This is the info stream{color:#9a9999}[Pipeline] }{color}{color:#9a9999}[Pipeline] // stage{color}
          Notice that the verbose stream is not written to the console. I propose a new flag for the powershell step, which would allow user-selected streams (such as Verbose and Debug) to be output to console.

          To get these streams in powershell, it is generally only necessary to use the common parameters -Debug and -Verbose when calling the script. See this link for more information:

          [https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_commonparameters?view=powershell-5.1]

           

          See also this blog post on streams in powershell:

          https://blogs.technet.microsoft.com/heyscriptingguy/2014/03/30/understanding-streams-redirection-and-write-host-in-powershell/

           
          New: Consider this declarative pipeline:

          {{pipeline \{}}
           {{    agent \{label 'MachineCompileDashboard'}}}

          {{    stages \{}}
           {{        stage('Deploy') \{}}
           {{            steps \{}}
           {{                powershell 'Write-Verbose \'This is the verbose stream\''}}
           {{                powershell 'Write-Information \'This is the info stream\''}}
           \{\{            }}}
           \{\{        }}}
           \{\{    }}}
           {{}}}

          The console output looks like this:

          {{ {color:#9a9999}[Pipeline] // stage{color}{color:#9a9999}[Pipeline] stage{color}{color:#9a9999}[Pipeline] \{ (Deploy){color}{color:#9a9999}[Pipeline] powershell{color}[microservice-helpers] Running PowerShell script{color:#9a9999}[Pipeline] powershell{color}[microservice-helpers] Running PowerShell script}}
          {{ This is the info stream{color:#9a9999}[Pipeline] }{color}{color:#9a9999}[Pipeline] // stage{color}}}


          Notice that the verbose stream is not written to the console. I propose a new flag for the powershell step, which would allow user-selected streams (such as Verbose and Debug) to be output to console.

          To get these streams in powershell, it is generally only necessary to use the common parameters -Debug and -Verbose when calling the script. See this link for more information:

          [https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_commonparameters?view=powershell-5.1]

           

          See also this blog post on streams in powershell:

          [https://blogs.technet.microsoft.com/heyscriptingguy/2014/03/30/understanding-streams-redirection-and-write-host-in-powershell/]

           
          Francis Therien made changes -
          Description Original: Consider this declarative pipeline:

          {{pipeline \{}}
           {{    agent \{label 'MachineCompileDashboard'}}}

          {{    stages \{}}
           {{        stage('Deploy') \{}}
           {{            steps \{}}
           {{                powershell 'Write-Verbose \'This is the verbose stream\''}}
           {{                powershell 'Write-Information \'This is the info stream\''}}
           \{\{            }}}
           \{\{        }}}
           \{\{    }}}
           {{}}}

          The console output looks like this:

          {{ {color:#9a9999}[Pipeline] // stage{color}{color:#9a9999}[Pipeline] stage{color}{color:#9a9999}[Pipeline] \{ (Deploy){color}{color:#9a9999}[Pipeline] powershell{color}[microservice-helpers] Running PowerShell script{color:#9a9999}[Pipeline] powershell{color}[microservice-helpers] Running PowerShell script}}
          {{ This is the info stream{color:#9a9999}[Pipeline] }{color}{color:#9a9999}[Pipeline] // stage{color}}}


          Notice that the verbose stream is not written to the console. I propose a new flag for the powershell step, which would allow user-selected streams (such as Verbose and Debug) to be output to console.

          To get these streams in powershell, it is generally only necessary to use the common parameters -Debug and -Verbose when calling the script. See this link for more information:

          [https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_commonparameters?view=powershell-5.1]

           

          See also this blog post on streams in powershell:

          [https://blogs.technet.microsoft.com/heyscriptingguy/2014/03/30/understanding-streams-redirection-and-write-host-in-powershell/]

           
          New: Consider this declarative pipeline:

          {code:title=Jenkinsfile|borderStyle=solid}
          pipeline
           {{    agent \{label 'MachineCompileDashboard'}}}

          {{    stages \{}}
           {{        stage('Deploy') \{}}
           {{            steps \{}}
           {{                powershell 'Write-Verbose \'This is the verbose stream\''}}
           {{                powershell 'Write-Information \'This is the info stream\''}}
           \{\{            }}}
           \{\{        }}}
           \{\{    }}}
          {code}

          The console output looks like this:

          {quote}
          {color:#9a9999}[Pipeline] // stage{color}
          {color:#9a9999}[Pipeline] stage{color}
          {color:#9a9999}[Pipeline] \{ (Deploy){color}
          {color:#9a9999}[Pipeline] powershell{color}[microservice-helpers] Running PowerShell script
          {color:#9a9999}[Pipeline] powershell{color}[microservice-helpers] Running PowerShell script
          This is the info stream{color:#9a9999}[Pipeline] }{color}{color:#9a9999}[Pipeline] // stage{color}
          {quote}

          Notice that the verbose stream is not written to the console. I propose a new flag for the powershell step, which would allow user-selected streams (such as Verbose and Debug) to be output to console.

          To get these streams in powershell, it is generally only necessary to use the common parameters -Debug and -Verbose when calling the script. See this link for more information:

          [https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_commonparameters?view=powershell-5.1]

           

          See also this blog post on streams in powershell:

          [https://blogs.technet.microsoft.com/heyscriptingguy/2014/03/30/understanding-streams-redirection-and-write-host-in-powershell/]

           
          Francis Therien made changes -
          Description Original: Consider this declarative pipeline:

          {code:title=Jenkinsfile|borderStyle=solid}
          pipeline
           {{    agent \{label 'MachineCompileDashboard'}}}

          {{    stages \{}}
           {{        stage('Deploy') \{}}
           {{            steps \{}}
           {{                powershell 'Write-Verbose \'This is the verbose stream\''}}
           {{                powershell 'Write-Information \'This is the info stream\''}}
           \{\{            }}}
           \{\{        }}}
           \{\{    }}}
          {code}

          The console output looks like this:

          {quote}
          {color:#9a9999}[Pipeline] // stage{color}
          {color:#9a9999}[Pipeline] stage{color}
          {color:#9a9999}[Pipeline] \{ (Deploy){color}
          {color:#9a9999}[Pipeline] powershell{color}[microservice-helpers] Running PowerShell script
          {color:#9a9999}[Pipeline] powershell{color}[microservice-helpers] Running PowerShell script
          This is the info stream{color:#9a9999}[Pipeline] }{color}{color:#9a9999}[Pipeline] // stage{color}
          {quote}

          Notice that the verbose stream is not written to the console. I propose a new flag for the powershell step, which would allow user-selected streams (such as Verbose and Debug) to be output to console.

          To get these streams in powershell, it is generally only necessary to use the common parameters -Debug and -Verbose when calling the script. See this link for more information:

          [https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_commonparameters?view=powershell-5.1]

           

          See also this blog post on streams in powershell:

          [https://blogs.technet.microsoft.com/heyscriptingguy/2014/03/30/understanding-streams-redirection-and-write-host-in-powershell/]

           
          New: Consider this declarative pipeline:

          {code:title=Jenkinsfile|borderStyle=solid}
          pipeline {
              agent any

              stages {
                  stage('Deploy') {
                      steps {
                          powershell 'Write-Verbose \'This is the verbose stream\''
                          powershell 'Write-Information \'This is the info stream\''
                      }
                  }
              }
          }
          {code}

          The console output looks like this:

          {quote}
          {color:#9a9999}[Pipeline] // stage{color}
          {color:#9a9999}[Pipeline] stage{color}
          {color:#9a9999}[Pipeline] \{ (Deploy){color}
          {color:#9a9999}[Pipeline] powershell{color}[microservice-helpers] Running PowerShell script
          {color:#9a9999}[Pipeline] powershell{color}[microservice-helpers] Running PowerShell script
          This is the info stream{color:#9a9999}[Pipeline] }{color}{color:#9a9999}[Pipeline] // stage{color}
          {quote}

          Notice that the verbose stream is not written to the console. I propose a new flag for the powershell step, which would allow user-selected streams (such as Verbose and Debug) to be output to console.

          To get these streams in powershell, it is generally only necessary to use the common parameters -Debug and -Verbose when calling the script. See this link for more information:

          [https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_commonparameters?view=powershell-5.1]

           

          See also this blog post on streams in powershell:

          [https://blogs.technet.microsoft.com/heyscriptingguy/2014/03/30/understanding-streams-redirection-and-write-host-in-powershell/]

           
          Francis Therien made changes -
          Description Original: Consider this declarative pipeline:

          {code:title=Jenkinsfile|borderStyle=solid}
          pipeline {
              agent any

              stages {
                  stage('Deploy') {
                      steps {
                          powershell 'Write-Verbose \'This is the verbose stream\''
                          powershell 'Write-Information \'This is the info stream\''
                      }
                  }
              }
          }
          {code}

          The console output looks like this:

          {quote}
          {color:#9a9999}[Pipeline] // stage{color}
          {color:#9a9999}[Pipeline] stage{color}
          {color:#9a9999}[Pipeline] \{ (Deploy){color}
          {color:#9a9999}[Pipeline] powershell{color}[microservice-helpers] Running PowerShell script
          {color:#9a9999}[Pipeline] powershell{color}[microservice-helpers] Running PowerShell script
          This is the info stream{color:#9a9999}[Pipeline] }{color}{color:#9a9999}[Pipeline] // stage{color}
          {quote}

          Notice that the verbose stream is not written to the console. I propose a new flag for the powershell step, which would allow user-selected streams (such as Verbose and Debug) to be output to console.

          To get these streams in powershell, it is generally only necessary to use the common parameters -Debug and -Verbose when calling the script. See this link for more information:

          [https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_commonparameters?view=powershell-5.1]

           

          See also this blog post on streams in powershell:

          [https://blogs.technet.microsoft.com/heyscriptingguy/2014/03/30/understanding-streams-redirection-and-write-host-in-powershell/]

           
          New: Consider this declarative pipeline:

          {code:title=Jenkinsfile|borderStyle=solid}
          pipeline {
              agent any

              stages {
                  stage('Deploy') {
                      steps {
                          powershell 'Write-Verbose \'This is the verbose stream\''
                          powershell 'Write-Information \'This is the info stream\''
                      }
                  }
              }
          }
          {code}

          The console output looks like this:

          {quote}
          {color:#9a9999}[Pipeline] // stage{color}
          {color:#9a9999}[Pipeline] stage{color}
          {color:#9a9999}[Pipeline] \{ (Deploy){color}
          {color:#9a9999}[Pipeline] powershell{color}[microservice-helpers] Running PowerShell script
          {color:#9a9999}[Pipeline] powershell{color}[microservice-helpers] Running PowerShell script
          This is the info stream
          {color:#9a9999}[Pipeline] }{color}
          {color:#9a9999}[Pipeline] // stage{color}
          {quote}

          Notice that the verbose stream is not written to the console. I propose a new flag for the powershell step, which would allow user-selected streams (such as Verbose and Debug) to be output to console.

          To get these streams in powershell, it is generally only necessary to use the common parameters -Debug and -Verbose when calling the script. See this link for more information:

          [https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_commonparameters?view=powershell-5.1]

           

          See also this blog post on streams in powershell:

          [https://blogs.technet.microsoft.com/heyscriptingguy/2014/03/30/understanding-streams-redirection-and-write-host-in-powershell/]

           
          Francis Therien made changes -
          Description Original: Consider this declarative pipeline:

          {code:title=Jenkinsfile|borderStyle=solid}
          pipeline {
              agent any

              stages {
                  stage('Deploy') {
                      steps {
                          powershell 'Write-Verbose \'This is the verbose stream\''
                          powershell 'Write-Information \'This is the info stream\''
                      }
                  }
              }
          }
          {code}

          The console output looks like this:

          {quote}
          {color:#9a9999}[Pipeline] // stage{color}
          {color:#9a9999}[Pipeline] stage{color}
          {color:#9a9999}[Pipeline] \{ (Deploy){color}
          {color:#9a9999}[Pipeline] powershell{color}[microservice-helpers] Running PowerShell script
          {color:#9a9999}[Pipeline] powershell{color}[microservice-helpers] Running PowerShell script
          This is the info stream
          {color:#9a9999}[Pipeline] }{color}
          {color:#9a9999}[Pipeline] // stage{color}
          {quote}

          Notice that the verbose stream is not written to the console. I propose a new flag for the powershell step, which would allow user-selected streams (such as Verbose and Debug) to be output to console.

          To get these streams in powershell, it is generally only necessary to use the common parameters -Debug and -Verbose when calling the script. See this link for more information:

          [https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_commonparameters?view=powershell-5.1]

           

          See also this blog post on streams in powershell:

          [https://blogs.technet.microsoft.com/heyscriptingguy/2014/03/30/understanding-streams-redirection-and-write-host-in-powershell/]

           
          New: Consider this declarative pipeline:
          {code:java|title=Jenkinsfile|borderStyle=solid}
          pipeline {
              agent any

              stages {
                  stage('Deploy') {
                      steps {
                          powershell 'Write-Verbose \'This is the verbose stream\''
                          powershell 'Write-Information \'This is the info stream\''
                      }
                  }
              }
          }
          {code}
          The console output looks like this:
          {quote}{color:#9a9999}[Pipeline] // stage{color}
           {color:#9a9999}[Pipeline] stage{color}
           {color:#9a9999}[Pipeline] \{ (Deploy){color}
           {color:#9a9999}[Pipeline] powershell{color}[microservice-helpers] Running PowerShell script
           {color:#9a9999}[Pipeline] powershell{color}[microservice-helpers] Running PowerShell script
           This is the info stream
           {color:#9a9999}[Pipeline] }{color}
           {color:#9a9999}[Pipeline] // stage{color}
          {quote}
          Notice that the verbose stream is not written to the console. I propose a new flag for the powershell step, which would allow user-selected streams (such as Verbose and Debug) to be output to console.

          To get these streams in powershell, it is generally only necessary to use the common parameters -Debug and -Verbose when calling the script. See this link for more information:

          Another way to trigger output of the verbose stream is to set {{$VerbosePreference = 'Continue'}} at a global level in the shell before running the actual script.

          [https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_commonparameters?view=powershell-5.1]

           

          See also this blog post on streams in powershell:

          [https://blogs.technet.microsoft.com/heyscriptingguy/2014/03/30/understanding-streams-redirection-and-write-host-in-powershell/]

           
          Francis Therien made changes -
          Description Original: Consider this declarative pipeline:
          {code:java|title=Jenkinsfile|borderStyle=solid}
          pipeline {
              agent any

              stages {
                  stage('Deploy') {
                      steps {
                          powershell 'Write-Verbose \'This is the verbose stream\''
                          powershell 'Write-Information \'This is the info stream\''
                      }
                  }
              }
          }
          {code}
          The console output looks like this:
          {quote}{color:#9a9999}[Pipeline] // stage{color}
           {color:#9a9999}[Pipeline] stage{color}
           {color:#9a9999}[Pipeline] \{ (Deploy){color}
           {color:#9a9999}[Pipeline] powershell{color}[microservice-helpers] Running PowerShell script
           {color:#9a9999}[Pipeline] powershell{color}[microservice-helpers] Running PowerShell script
           This is the info stream
           {color:#9a9999}[Pipeline] }{color}
           {color:#9a9999}[Pipeline] // stage{color}
          {quote}
          Notice that the verbose stream is not written to the console. I propose a new flag for the powershell step, which would allow user-selected streams (such as Verbose and Debug) to be output to console.

          To get these streams in powershell, it is generally only necessary to use the common parameters -Debug and -Verbose when calling the script. See this link for more information:

          Another way to trigger output of the verbose stream is to set {{$VerbosePreference = 'Continue'}} at a global level in the shell before running the actual script.

          [https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_commonparameters?view=powershell-5.1]

           

          See also this blog post on streams in powershell:

          [https://blogs.technet.microsoft.com/heyscriptingguy/2014/03/30/understanding-streams-redirection-and-write-host-in-powershell/]

           
          New: Consider this declarative pipeline:
          {code:java|title=Jenkinsfile|borderStyle=solid}
          pipeline {
              agent any

              stages {
                  stage('Deploy') {
                      steps {
                          powershell 'Write-Verbose \'This is the verbose stream\''
                          powershell 'Write-Information \'This is the info stream\''
                      }
                  }
              }
          }
          {code}
          The console output looks like this:
          {quote}{color:#9a9999}[Pipeline] // stage{color}
           {color:#9a9999}[Pipeline] stage{color}
           {color:#9a9999}[Pipeline] \{ (Deploy){color}
           {color:#9a9999}[Pipeline] powershell{color}[microservice-helpers] Running PowerShell script
           {color:#9a9999}[Pipeline] powershell{color}[microservice-helpers] Running PowerShell script
           This is the info stream
           {color:#9a9999}[Pipeline] }{color}
           {color:#9a9999}[Pipeline] // stage{color}
          {quote}
          Notice that the verbose stream is not written to the console. I propose a new flag for the powershell step, which would allow user-selected streams (such as Verbose and Debug) to be output to console.

          To get these streams in powershell, it is generally only necessary to use the common parameters -Debug and -Verbose when calling the script. See this link for more information:

          [https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_commonparameters?view=powershell-5.1]

          Another way to trigger output of the verbose stream is to set {{$VerbosePreference = 'Continue'}} at a global level in the shell before running the actual script.
           

          See also this blog post on streams in powershell:

          [https://blogs.technet.microsoft.com/heyscriptingguy/2014/03/30/understanding-streams-redirection-and-write-host-in-powershell/]

           

            Unassigned Unassigned
            ftherien Francis Therien
            Votes:
            4 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: