1

This question is related to my previous question here: How to pass a value from JSON to a command in shell script at Docker?

I have a shell script file as below:

name=$(jq '.name' /xxx/deploy-tool.json)
nugetFileVersion=$(jq '.version' /xxx/deploy-tool.json)
#bash
#echo $name

# TODO how to pass value from JSON to the command below
# install dot net nuget
dotnet tool install -g $name --version $nugetFileVersion --add-source /xxx/

Here is my deploy-tool.json file

{
    "name": "xxx.DEPLOY",
    "version": "1.2.0-dev.29"
}

When I run the script above in the dockerfile, I got an error message saying:

Specified version '"1.2.0-dev.29"' is not a valid NuGet version range.

I tried to check dotnet-tool install documentation here: https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-tool-install However, I could not find anything useful.

How do I pass the nugetFileVersion from the jq command to the dotnet tool install's version parameter like how I managed to do so in powershell like the image below: powershell command OK

Thank you

user2150279
  • 445
  • 2
  • 8
  • 17
  • 1
    your version number is double quoted. Try `name=$(jq -r '.name' /xxx/deploy-tool.json)` `nugetFileVersion=$(jq -r '.version' /xxx/deploy-tool.json)` – Sufiyan Ghori Sep 08 '19 at 23:53

1 Answers1

0

When you run jq .version you get the output "1.2.0-dev.29". You need it without the quotes. To get that, add -r (--raw-output) to your jq call:

jq -r '.version' yourfile
knittl
  • 246,190
  • 53
  • 318
  • 364