microsoft / vso-agent

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

Shell Script task Working Directory other than root or folder script is in does not work #299

Closed j0tt closed 8 years ago

j0tt commented 8 years ago

I recently updated my agents only to find working directory does not appear to be working for my shell script tasks on my on-prem mac build agents.

Steps to reproduce: Create a build with a Shell Script task

Observe in the build output the working directory is the directory the script resides in, not the directory specified in the task.

bryanmacfarlane commented 8 years ago

what's the version of your shellscript task (_work/tasks ...) Also, what's the version of your agent?

ericsciple commented 8 years ago

Also what inputs (and exactly what values) are you specifying on the shellscript task?

j0tt commented 8 years ago

@bryanmacfarlane the shellscript task is using 2.0.0. I just updated the agents, VSO says Agent.Version = 1.999.0 but I'm dubious that is correct. Is there a better place to verify that?

@ericsciple generalizing as best I can: Script Path: dir/dir/script.sh Working Directory: dir/dir/dir

bryanmacfarlane commented 8 years ago

Agent version is in package.json file in the root of the agent and it's reported as npm version in agent capabilities from the admin web UI.

j0tt commented 8 years ago

We have at least 4 agents with this issue, all of varying Agent.NpmVersions (forgive me, I just inherited this environment): 0.5.9, 0.3.4, 0.2.28, 0.3.3

bryanmacfarlane commented 8 years ago

If the agent is updated, it should be 0.6.x

Trying to repro with 0.6.x

j0tt commented 8 years ago

Okay, I knew I updated them... VSO is reporting the wrong versions under Agent.NpmVersion. Interrogating the package.jason file I see 0.6.5 on all agents.

bryanmacfarlane commented 8 years ago

OK. I got a repro and I have a fix.

If you want to confirm on your agent. _work/tasks/ShellScript/2.0.0/shellscript.js change line 21 from

        if (!tl.filePathSupplied(cwd)) {

to

        if (!tl.filePathSupplied('cwd')) {

It takes input name (not value) as the arg. The issue was masked in the case of picking the folder as cwd or root.

bryanmacfarlane commented 8 years ago

Fixed in https://github.com/Microsoft/vsts-tasks/commit/4cf73301a50e49ce27b91350f0055e834cd26fe6

j0tt commented 8 years ago

Awesome. Thanks for the quick turnaround!

bryanmacfarlane commented 8 years ago

np. sorry for the inconvenience.