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

WORKSPACE env variable is incorrect for matrix project on windows slaves

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • matrix-project-plugin
    • None
    • master on unix (solaris)
      slave on windows

      WORKSPACE environment variable should have a windows format on windows platform.
      The synthax is <Hudson_Root>\workspace\<project name>\label/windows if (windows is the node alias)
      This is for me a major drawback as workspace env variable is important.

      To reproduce:
      I create a matrix project "test_matrix" executed on 2 nodes (windows & solaris) for each platform define an env ARCH var=sunos/winnt
      -------- configure ant task and a build.xml to execute a windows or unix script according platform.
      <?xml version='1.0'?>
      <project name="MyTest" default="test" basedir=".">
      <property environment="env"/>
      <taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
      <target name="test" description="run test">
      <if>
      <equals arg1="${env.ARCH}" arg2="winnt" />
      <then>
      <echo>Launch compilations on winnt: ${env.ARCH}</echo>
      <exec executable="runKDBcc.bat" failonerror="true" />
      </then>
      <else>
      <echo>Launch compilations on unix: ${env.ARCH}</echo>
      <exec executable="runKDBcc.sh" failonerror="true" />
      </else>
      </if>
      </target>
      </project>
      ------- script for solaris unix
      runKDBcc.sh
      #! /bin/sh
      echo $WORKSPACE
      cd $WORKSPACE
      ------- script for windows
      runKDBcc.bat
      echo %WORKSPACE%
      cd %WORKSPACE%

      ------- The results on windows with workspace bad name after label.

      test:
      [echo] Launch compilations on winnt: winnt
      [exec]
      [exec] The syntax of the command is incorrect.
      [exec] C:\slave_hudson\workspace\test_matrix\label\winnt>echo C:\slave_hudson\workspace\test_matrix\label/winnt
      [exec] C:\slave_hudson\workspace\test_matrix\label/winnt
      [exec]
      [exec] C:\slave_hudson\workspace\test_matrix\label\winnt>cd C:\slave_hudson\workspace\test_matrix\label/winnt
      [exec]

          [JENKINS-5084] WORKSPACE env variable is incorrect for matrix project on windows slaves

          salimfadhley added a comment -

          FYI, this also fails if the Master + Slave are both Windows. The master environment seems to be completely irrelivant.

          Suggest that the matrix-job code needs to use an OS-aware method for forming the workspace.

          salimfadhley added a comment - FYI, this also fails if the Master + Slave are both Windows. The master environment seems to be completely irrelivant. Suggest that the matrix-job code needs to use an OS-aware method for forming the workspace.

          echo %WORKSPACE% shows this:

          [DFWW9202] $ cmd /c call C:\WINDOWS\TEMP\hudson5691415072050770333.bat
          Workspace is at C:\Data\Hudson\dev\workspace\Common_Windows\label/DFWW9202

          Where DFWW9002 is the name of the computer. This is a major issue since the variable cannot be used because of the last slash being the wrong one for the Windows environment

          Sagar Khushalani added a comment - echo %WORKSPACE% shows this: [DFWW9202] $ cmd /c call C:\WINDOWS\TEMP\hudson5691415072050770333.bat Workspace is at C:\Data\Hudson\dev\workspace\Common_Windows\label/DFWW9202 Where DFWW9002 is the name of the computer. This is a major issue since the variable cannot be used because of the last slash being the wrong one for the Windows environment

          bult added a comment -

          workaround: before executing your commands execute
          set WORKSPACE=%WORKSPACE:/=%

          AFAIK, problem occurs only with 'pushd' command.

          bult added a comment - workaround: before executing your commands execute set WORKSPACE=%WORKSPACE:/=% AFAIK, problem occurs only with 'pushd' command.

          Christoph Jaehnigen added a comment - - edited

          Corrected workaround:

          set WORKSPACE=%WORKSPACE:/=\%

          Christoph Jaehnigen added a comment - - edited Corrected workaround: set WORKSPACE=%WORKSPACE:/=\%

          Daniel Beck added a comment -

          Issue still current in extracted Matrix Project Plugin:

          https://github.com/jenkinsci/matrix-project-plugin/blob/master/src/main/java/hudson/matrix/MatrixRun.java#L176
          https://github.com/jenkinsci/matrix-project-plugin/blob/master/src/main/java/hudson/matrix/MatrixProject.java#L226

          Workaround: Set System property -Dhudson.matrix.MatrixConfiguration.useShortWorkspaceName=true to use a short digest instead of the full axes combination as matrix child workspace. Also helps on Windows.

          Daniel Beck added a comment - Issue still current in extracted Matrix Project Plugin: https://github.com/jenkinsci/matrix-project-plugin/blob/master/src/main/java/hudson/matrix/MatrixRun.java#L176 https://github.com/jenkinsci/matrix-project-plugin/blob/master/src/main/java/hudson/matrix/MatrixProject.java#L226 Workaround: Set System property -Dhudson.matrix.MatrixConfiguration.useShortWorkspaceName=true to use a short digest instead of the full axes combination as matrix child workspace. Also helps on Windows.

          Daniel Beck added a comment -

          Adjusting priority and component based on information in comments.

          Daniel Beck added a comment - Adjusting priority and component based on information in comments.

            Unassigned Unassigned
            erwan_q erwan_q
            Votes:
            9 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated: