Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command arguments Quotations not visible in Linux agent logs #383

Closed
vithati opened this issue Jul 26, 2018 · 4 comments
Closed

Command arguments Quotations not visible in Linux agent logs #383

vithati opened this issue Jul 26, 2018 · 4 comments
Assignees
Labels

Comments

@vithati
Copy link
Member

vithati commented Jul 26, 2018

I am using docker run task to execute a one liner script in a container just build in the pipeline. The idea is to execute:

docker run -t my-container sh -c "ls .Test/.csproj | xargs -L1 dotnet test -c Release --logger:trx -r ../../test_out"

So I set up a docker run task and pass sh -c "ls .Test/.csproj | xargs -L1 dotnet test -c Release --logger:trx -r ../../test_out" in the field Command.

To my surprise, the double quotes disappear and there fore the actual command executed by the agent is (from the task output)

docker run -t my-container sh -c ls .Test/.csproj | xargs -L1 dotnet test -c Release --logger:trx -r ../../test_out

There is no failure in executing command, just quotation not visible in logs.

In windows agent, logs showing properly. docker run -t my-container sh -c "ls .Test/.csproj | xargs -L1 dotnet test -c Release --logger:trx -r ../../test_out"

@vithati
Copy link
Member Author

vithati commented Jul 26, 2018

I looked at code https://github.com/Microsoft/vsts-task-lib/blob/f22b24bd393becbb370b95f394e3f2cdcc823964/node/toolrunner.ts , looks like for linux, quotations not handled like windows.

@damccorm
Copy link

I can't say for sure, but if you are passing that in as a string it could be an issue with _argStringToArray. If so, passing something like docker run -t my-container sh -c "\"ls .Test/.csproj | xargs -L1 dotnet test -c Release --logger:trx -r ../../test_out\"" should solve it. Right now, it sees that you have quotes and thinks that you just want to avoid splitting it up into different args (which I assume is true). Escaping should fix that.

If that doesn't resolve it, I'll take a deeper look - I'm somewhat confused as to why it would work with Windows and not Linux

@damccorm
Copy link

I'm going to close, please reopen if appropriate.

@beatcracker
Copy link

I'm going to close, please reopen if appropriate.

I'm not sure if it's the right place to report this, but escaping seems to be inconsistent:

Here is the Docker task I'm using in the classic release pipeline:

  • UI

image

  • YAML
steps:
- task: Docker@2
  inputs:
    command: run
    arguments: '{\"version\": \"$(Build.BuildNumber)\"}'

As you can see, I'm trying to pass a JSON as string (all other arguments are omitted for clarity) and it's not escaped correctly when task is run:

[command]/bin/docker run {\version": "1.2.3"}
/bin/docker: invalid reference format.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants