title: Using the sh step on Windows
body: <p><strong>TL;DR</strong> <em>I want to use the <code>sh</code> step even though Jenkins is running on Windows. I do not want to use the <code>bat</code> step, unless you can show me how to easily reproduce what I need done using <code>bat</code></em></p>
  
  <p>I've been converting some old Jenkins jobs over to 2.x Pipeline script. One of my jobs uses the "Publish over SSH plugin" to:</p>
  
  <ul>
  <li>Send artifacts to a remote server</li>
  <li>Exec a set of commands on the remote server</li>
  </ul>
  
  <p>For instance:</p>
  
  <p><a href="https://i.stack.imgur.com/bLR2K.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/bLR2K.jpg" alt="Publish over SSH plugin"></a></p>
  
  <p>I wanted to replicate this in Pipeline Script so I've done the following:</p>
  
  <pre><code>   stage('Deploy') {
      withCredentials([[$class: 'FileBinding', credentialsId: 'bitbucket-key-file', variable: 'SSHKEY']]) {
          sh '''
              scp -i "$SSHKEY" dsub.tar.gz tprmbbuild@192.168.220.57:dsubdeploy
              scp -i "$SSHKEY" deployDsubUi.sh tprmbbuild@192.168.220.57:dsubdeploy
              ssh -i "$SSHKEY" -o StrictHostKeyChecking=no 192.168.220.57 &lt;&lt;- EOF
                  DEPLOY_DIR=/home/tprmbbuild/dsubdeploy
                  echo '*** dos2unix using sed'
                  sed -e 's/\r$//' $DEPLOY_DIR/deployDsubUi.sh &gt; $DEPLOY_DIR/deployDsubUi-new.sh
                  mv $DEPLOY_DIR/deployDsubUi-new.sh $DEPLOY_DIR/deployDsubUi.sh
                  chmod 755 $DEPLOY_DIR/deployDsubUi.sh
                  echo '*** Deploying Dsub UI'
                  $DEPLOY_DIR/deployDsubUi.sh $DEPLOY_DIR/dsub.tar.gz
              EOF'''
      }
     }
  </code></pre>
  
  <p>Problem is, I get this stack trace when executing my build:</p>
  
  <pre><code>[Pipeline] sh
  [E:\Jenkins\jenkins_home\workspace\tpr-ereg-ui-deploy@2] Running shell script
        1 [main] sh 3588 E:\Jenkins\tools\Git_2.10.1\usr\bin\sh.exe: *** fatal error - add_item ("\??\E:\Jenkins\tools\Git_2.10.1", "/", ...) failed, errno 1
  Stack trace:
  Frame        Function    Args
  000FFFF9BB0  0018005C24E (0018023F612, 0018021CC39, 000FFFF9BB0, 000FFFF8B30)
  000FFFF9BB0  001800464B9 (000FFFFABEE, 000FFFF9BB0, 1D2345683BEC046, 00000000000)
  000FFFF9BB0  001800464F2 (000FFFF9BB0, 00000000001, 000FFFF9BB0, 4A5C3A455C3F3F5C)
  000FFFF9BB0  001800CAA8B (00000000000, 000FFFFCE00, 001800BA558, 1D234568CAFA549)
  000FFFFCC00  00180118745 (00000000000, 00000000000, 001800B2C5E, 00000000000)
  000FFFFCCC0  00180046AE5 (00000000000, 00000000000, 00000000000, 00000000000)
  00000000000  00180045753 (00000000000, 00000000000, 00000000000, 00000000000)
  000FFFFFFF0  00180045804 (00000000000, 00000000000, 00000000000, 00000000000)
  End of stack trace
  </code></pre>