microsoft / vso-agent

Visual Studio Team Services and TFS agent for Mac OSX and Linux
MIT License
132 stars 57 forks source link

Not found: cwd running the Cmake task on linux with working directory set to $(Build.StagingDirectory) #249

Closed cgapeart closed 8 years ago

cgapeart commented 8 years ago

This issue is tied to the latest release, and did not exist in the previous release. I had a build system up and running last week, and when I tried to build a fresh one this week, the cmake task and everything after that didn't work.

My cmake build was working based on vsoagent-installer@0.4.5. My second machine which I set up a week later got vsoagent-installer@0.5.9.

The error message I recieved was as follows:

[Error] 2016-03-11T00:52:34.803Z: Not found cwd: /home/vsoagent/BuildAgent/_work/2/s//home/vsoagent/BuildAgent/_work/2/a

I have traced this to the cmake2.js file in the _work/tasks/CMake/1.0.9 path. I have confirmed through logging that the path in the error message is exactly what the task gets when it calls

var cwd = tl.getPathInput('cwd', false);

As you can see, the cwd input passed into the cmake task has been resolved incorrectly - instead of treating $(Build.StagingDirectory) as an absolute path, it is attached it to the source directory.

consequently, the task fails when it calls tl.checkPath(cwd, 'cwd');

I consider this a break - I had a working build, that stopped working, but I could be wrong there. For CMake, it is awefully convenient to use $(Build.StagingDirectory) to run the build in, instead of creating a subtree inside the source folder. That being said, perhaps using $(Build.StagingDirectory) is not the right way to use the staging directory?

I was able to trace the rewriting of the path to the prepare phase, before the task was called. I believe it was happening in agent/job.js, in JobRunner processInputs call. I have managed to lose all of the logs, but I can reproduce them if more information is needed to discuss the issue. The first sighting of the variable getting expanded incorrectly was logged starting with "rewriting value for "...

I was never able to get a build working with any other value for the working directory in my build script: I am sure with enough poking around I could have gotten all of my commands running properly, but it was easier to just copy the build agent from my first working machine to the new one instead of starting from scratch. However, manually edit the test result publisher to be able to publish my unit test xml results from googletest -- it looks like that bug was already fixed in the newer version.

bryanmacfarlane commented 8 years ago

This is fixed in 0.6.1 agent