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

Pipeline running on OSX can't run 'bat' on Windows node

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Not A Defect
    • Component/s: pipeline
    • Labels:
      None
    • Environment:
      Jenkins 2.34
      Pipeline 2.4
    • Similar Issues:

      Description

      Our Jenkins is using OSX, while our slave is running Windows. When I try to run a pipeline script that runs on the Windows slave, I get an error while trying to execute the bat step. It looks like master is trying to run the command (and failing) when it should run fine in a Windows environment.

      Pipeline code

      node('windowsSlave') {
      
              def nodeWorkspace = pwd() + "@script"
      
              def baseGatlingDir = "${nodeWorkspace}\\Gatling_Tests"
              def gatlingTargetDir = "${baseGatlingDir}\\target"
      
              stage('Clear Previous Test Results') {
                  dir("${gatlingTargetDir}") {
                      deleteDir()
                  }
              }
      
              stage('Maven Compile') {
                  dir("${baseGatlingDir}") {
                      bat "mvn test-compile"
                  }
              }
      

      Console output

      [Pipeline] node
      Running on windowsSlave in C:\Jenkins\workspace\Gatling\Pipeline - Acceptance Simulation
      [Pipeline] {
      [Pipeline] pwd
      [Pipeline] stage
      [Pipeline] { (Clear Previous Test Results)
      [Pipeline] dir
      Running in C:\Jenkins\workspace\Gatling\Pipeline - Acceptance Simulation@script\Gatling_Tests\target
      [Pipeline] {
      [Pipeline] deleteDir
      [Pipeline] }
      [Pipeline] // dir
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] stage
      [Pipeline] { (Maven Compile)
      [Pipeline] dir
      Running in C:\Jenkins\workspace\Gatling\Pipeline - Acceptance Simulation@script\Gatling_Tests
      [Pipeline] {
      [Pipeline] bat
      [Gatling_Tests] Running batch script
      'cmd' is not recognized as an internal or external command,
      operable program or batch file.
      

        Attachments

          Issue Links

            Activity

            Hide
            civilizeddev Hyeonsoo Lee added a comment -

            I have experienced the same issue.

            When I use only one node() for windows machine in the Jenkinsfile, it works.

            But when I build on the master node(Linux) and run commands on the slave node(Windows), so there are multiple node() directives in the Jenkinsfile, it fails.

            bat() inside node("for-slave") { ... } doesn't seem to be running on the slave(Windows).

            Show
            civilizeddev Hyeonsoo Lee added a comment - I have experienced the same issue. When I use only one node() for windows machine in the Jenkinsfile, it works. But when I build on the master node(Linux) and run commands on the slave node(Windows), so there are multiple node() directives in the Jenkinsfile, it fails. bat() inside node("for-slave") { ... } doesn't seem to be running on the slave(Windows).
            Show
            civilizeddev Hyeonsoo Lee added a comment - https://issues.jenkins-ci.org/browse/JENKINS-40338
            Hide
            cwcam Cam Spencer added a comment -

            Turns out this was classic PEBKAC...

            In "Manage Jenkins" > "Configure System" > "Global Properties" there was an override of PATH...

            Show
            cwcam Cam Spencer added a comment - Turns out this was classic  PEBKAC ... In "Manage Jenkins" > "Configure System" > "Global Properties" there was an override of PATH...

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              cwcam Cam Spencer
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: