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

bat(returnStdout: true) step returns the whole command not just the stdout

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Minor Minor
    • durable-task-plugin

      On a `pipeline` or `multibranch pipeline` job 

      The bat(returnStdout: true) step returns the whole command not just the stdout

      i.e

      node('windows') {
      
          stage('Checkout'){
              git('http://github.com/test/test')
              stdout = bat(returnStdout: true, script: 'git rev-parse HEAD')
              println("stdout ################ " + stdout + " ####################")
         }
      
      }
      

      returns

       

      stdout  ################ 
      C:\hudson\workspace\test_UT_pipeline_statuses-J5YZJ3FX5VOUPIOVLCDBLV55WCESHMXOR3K32NSM442TR2P4MNEQ>git rev-parse HEAD 
      ff0f0401354a0faa6cf9c08fd513beddb85997ec
       ####################
      

      instead of just

      ff0f0401354a0faa6cf9c08fd513beddb85997ec
      

      as it is done by the sh(returnStdout: true) function

       

      Workaround will be to discard the first line of the returned string

            Unassigned Unassigned
            fnaum Federico Naum
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: