-
Bug
-
Resolution: Fixed
-
Critical
-
None
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?
All projects generally are top-level items. It won't cover matrix axes and similar cases though, where project types divide their workspaces further.
What you could try is to determine the TopLevelItem ancestor of the current build's project, and get the workspace of that on the current node (e.g. /jenkins/workspace/foo). If that's a prefix of the current actual workspace (/jenkins/workspace/foo/bar/baz), just append the rest (/bar/baz) to the workspace path on master
It seems to me that the design of this feature is broken if you need to know about details like that, and an approximation and/or specifically adding support for job types is the best you can do.