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

"Copy files back to master node" doesn't copy to workspace

      I've a matrix job that uses the "Copy To Slave" plugin to "Copy files back to master node" as a post-build action. I then use the PostBuildScript plugin to run on the master node and process these files.

      However, even though Copy-to-Slave succeeds, the files aren't in the master workspace. Looking at the build output on the slaves shows:

      [copy-to-slave] Copying 'build/**/*', excluding nothing, from 'file:/home/foobar/jenkins/workspace/MyJob/label/foobar-ci-linux/' on 'hudson.slaves.DumbSlave@564c7adb' to 'file:/Users/foobar/.jenkins/jobs/MyJob/configurations/axis-label/foobar-ci-linux/workspace/' on the master.
      

      The path

      /Users/foobar/.jenkins/jobs/MyJob/configurations/axis-label/foobar-ci-linux/workspace/
      

      is not the workspace. The workspace is actually here:

      /Users/foobar/.jenkins/.jenkins/workspace/MyJob/
      

      Why does Copy-To-Slave copy the files to this weird path?

          [JENKINS-25346] "Copy files back to master node" doesn't copy to workspace

          Aaron Simmons created issue -
          Aaron Simmons made changes -
          Description Original: I've a matrix job that uses the "Copy To Slave" plugin to "Copy files back to master node" as a post-build action. I then use the PostBuildScript plugin to run on the master node to process these files.

          However, even though Copy-to-Slave succeeds, the files aren't in the master workspace. Look at the build output on the slaves shows:
          {code}
          [copy-to-slave] Copying 'build/**/*', excluding nothing, from 'file:/home/foobar/jenkins/workspace/JenkinsSandbox/label/foobar-ci-linux/' on 'hudson.slaves.DumbSlave@564c7adb' to 'file:/Users/foobar/.jenkins/jobs/JenkinsSandbox/configurations/axis-label/foobar-ci-linux/workspace/' on the master.
          {code}

          The path
          {code}
          /Users/foobar/.jenkins/jobs/JenkinsSandbox/configurations/axis-label/foobar-ci-linux/workspace/
          {code}
          is not the workspace. The workspace is actually here:
          {code}
          /Users/foobar/.jenkins/.jenkins/workspace/JenkinsSandbox/
          {code}

          Why does Copy-To-Slave copy the files to this weird path?

          New: I've a matrix job that uses the "Copy To Slave" plugin to "Copy files back to master node" as a post-build action. I then use the PostBuildScript plugin to run on the master node and process these files.

          However, even though Copy-to-Slave succeeds, the files aren't in the master workspace. Look at the build output on the slaves shows:
          {code}
          [copy-to-slave] Copying 'build/**/*', excluding nothing, from 'file:/home/foobar/jenkins/workspace/JenkinsSandbox/label/foobar-ci-linux/' on 'hudson.slaves.DumbSlave@564c7adb' to 'file:/Users/foobar/.jenkins/jobs/JenkinsSandbox/configurations/axis-label/foobar-ci-linux/workspace/' on the master.
          {code}

          The path
          {code}
          /Users/foobar/.jenkins/jobs/JenkinsSandbox/configurations/axis-label/foobar-ci-linux/workspace/
          {code}
          is not the workspace. The workspace is actually here:
          {code}
          /Users/foobar/.jenkins/.jenkins/workspace/JenkinsSandbox/
          {code}

          Why does Copy-To-Slave copy the files to this weird path?

          Aaron Simmons made changes -
          Description Original: I've a matrix job that uses the "Copy To Slave" plugin to "Copy files back to master node" as a post-build action. I then use the PostBuildScript plugin to run on the master node and process these files.

          However, even though Copy-to-Slave succeeds, the files aren't in the master workspace. Look at the build output on the slaves shows:
          {code}
          [copy-to-slave] Copying 'build/**/*', excluding nothing, from 'file:/home/foobar/jenkins/workspace/JenkinsSandbox/label/foobar-ci-linux/' on 'hudson.slaves.DumbSlave@564c7adb' to 'file:/Users/foobar/.jenkins/jobs/JenkinsSandbox/configurations/axis-label/foobar-ci-linux/workspace/' on the master.
          {code}

          The path
          {code}
          /Users/foobar/.jenkins/jobs/JenkinsSandbox/configurations/axis-label/foobar-ci-linux/workspace/
          {code}
          is not the workspace. The workspace is actually here:
          {code}
          /Users/foobar/.jenkins/.jenkins/workspace/JenkinsSandbox/
          {code}

          Why does Copy-To-Slave copy the files to this weird path?

          New: I've a matrix job that uses the "Copy To Slave" plugin to "Copy files back to master node" as a post-build action. I then use the PostBuildScript plugin to run on the master node and process these files.

          However, even though Copy-to-Slave succeeds, the files aren't in the master workspace. Looking at the build output on the slaves shows:
          {code}
          [copy-to-slave] Copying 'build/**/*', excluding nothing, from 'file:/home/foobar/jenkins/workspace/JenkinsSandbox/label/foobar-ci-linux/' on 'hudson.slaves.DumbSlave@564c7adb' to 'file:/Users/foobar/.jenkins/jobs/JenkinsSandbox/configurations/axis-label/foobar-ci-linux/workspace/' on the master.
          {code}

          The path
          {code}
          /Users/foobar/.jenkins/jobs/JenkinsSandbox/configurations/axis-label/foobar-ci-linux/workspace/
          {code}
          is not the workspace. The workspace is actually here:
          {code}
          /Users/foobar/.jenkins/.jenkins/workspace/JenkinsSandbox/
          {code}

          Why does Copy-To-Slave copy the files to this weird path?

          Aaron Simmons made changes -
          Description Original: I've a matrix job that uses the "Copy To Slave" plugin to "Copy files back to master node" as a post-build action. I then use the PostBuildScript plugin to run on the master node and process these files.

          However, even though Copy-to-Slave succeeds, the files aren't in the master workspace. Looking at the build output on the slaves shows:
          {code}
          [copy-to-slave] Copying 'build/**/*', excluding nothing, from 'file:/home/foobar/jenkins/workspace/JenkinsSandbox/label/foobar-ci-linux/' on 'hudson.slaves.DumbSlave@564c7adb' to 'file:/Users/foobar/.jenkins/jobs/JenkinsSandbox/configurations/axis-label/foobar-ci-linux/workspace/' on the master.
          {code}

          The path
          {code}
          /Users/foobar/.jenkins/jobs/JenkinsSandbox/configurations/axis-label/foobar-ci-linux/workspace/
          {code}
          is not the workspace. The workspace is actually here:
          {code}
          /Users/foobar/.jenkins/.jenkins/workspace/JenkinsSandbox/
          {code}

          Why does Copy-To-Slave copy the files to this weird path?

          New: I've a matrix job that uses the "Copy To Slave" plugin to "Copy files back to master node" as a post-build action. I then use the PostBuildScript plugin to run on the master node and process these files.

          However, even though Copy-to-Slave succeeds, the files aren't in the master workspace. Looking at the build output on the slaves shows:
          {code}
          [copy-to-slave] Copying 'build/**/*', excluding nothing, from 'file:/home/foobar/jenkins/workspace/MyJob/label/foobar-ci-linux/' on 'hudson.slaves.DumbSlave@564c7adb' to 'file:/Users/foobar/.jenkins/jobs/MyJob/configurations/axis-label/foobar-ci-linux/workspace/' on the master.
          {code}

          The path
          {code}
          /Users/foobar/.jenkins/jobs/MyJob/configurations/axis-label/foobar-ci-linux/workspace/
          {code}
          is not the workspace. The workspace is actually here:
          {code}
          /Users/foobar/.jenkins/.jenkins/workspace/MyJob/
          {code}

          Why does Copy-To-Slave copy the files to this weird path?

          Daniel Beck added a comment -

          Daniel Beck added a comment - This is a long obsolete default workspace location that was hard-coded into the plugin: https://github.com/jenkinsci/copy-to-slave-plugin/blob/master/src/main/java/com/michelin/cio/hudson/plugins/copytoslave/CopyToSlaveUtils.java#L57

          Dan Jarvis added a comment -

          I sponsored a $100 bounty on fixing this issue:
          https://freedomsponsors.org/issue/623/copy-files-back-to-master-node-doesnt-copy-to-workspace

          Please add to the bounty or fix the issue in the next 90 days to claim the money!

          Dan Jarvis added a comment - I sponsored a $100 bounty on fixing this issue: https://freedomsponsors.org/issue/623/copy-files-back-to-master-node-doesnt-copy-to-workspace Please add to the bounty or fix the issue in the next 90 days to claim the money!

          Vivekanand SV added a comment - - edited

          @Daniel, I have done the following code based on your comment ...

          < ----- DIFF START ---- >

          LINE 57

          DEL projectWorkspaceOnMaster = new FilePath(new File(freeStyleProject.getRootDir(), "workspace"));
          ADD projectWorkspaceOnMaster = freeStyleProject.getWorkspace();

          LINE 61

          DEL projectWorkspaceOnMaster = new FilePath(new File(project.getRootDir(), "workspace"));
          ADD projectWorkspaceOnMaster = project.getWorkspace();

          < ----- DIFF END ---- >

          Can I know your review comments for this please ?

          Vivekanand SV added a comment - - edited @Daniel, I have done the following code based on your comment ... < ----- DIFF START ---- > LINE 57 DEL projectWorkspaceOnMaster = new FilePath(new File(freeStyleProject.getRootDir(), "workspace")); ADD projectWorkspaceOnMaster = freeStyleProject.getWorkspace(); LINE 61 DEL projectWorkspaceOnMaster = new FilePath(new File(project.getRootDir(), "workspace")); ADD projectWorkspaceOnMaster = project.getWorkspace(); < ----- DIFF END ---- > Can I know your review comments for this please ?

          Daniel Beck added a comment -

          https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/model/AbstractProject.java#L498

          @deprecated as of 1.319

          This will not guarantee to point to the master node anyway.


          I'd try Jenkins.getInstance().getWorkspaceFor(project) as that'll return a workspace on the master node. Not sure whether it's correct in all cases in the context of this plugin as I don't use it.

          Daniel Beck added a comment - https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/model/AbstractProject.java#L498 @deprecated as of 1.319 This will not guarantee to point to the master node anyway. I'd try Jenkins.getInstance().getWorkspaceFor(project) as that'll return a workspace on the master node. Not sure whether it's correct in all cases in the context of this plugin as I don't use it.

          Vivekanand SV added a comment -

          I'll give it a try, thanks.

          Vivekanand SV added a comment - I'll give it a try, thanks.

          Vivekanand SV added a comment -

          @Daniel, getWorkspaceFor() accepts only an implementation of TopLevelItem, so this will work in case of a free style project, what about other cases ? I tried Jenkins javadoc for some time but I couldn't get a clue.

          Sorry for posting these questions, I don't have much knowledge about Jenkins code so looking for all help.

          Vivekanand SV added a comment - @Daniel, getWorkspaceFor() accepts only an implementation of TopLevelItem, so this will work in case of a free style project, what about other cases ? I tried Jenkins javadoc for some time but I couldn't get a clue. Sorry for posting these questions, I don't have much knowledge about Jenkins code so looking for all help.

            svvivek Vivekanand SV
            paleozogt Aaron Simmons
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: