jenkinsci / azure-cli-plugin

A Jenkins plugin to use Azure CLI for managing Azure resources.
https://plugins.jenkins.io/azure-cli/
MIT License
5 stars 18 forks source link

Spaces in bash variable for az group create tags #16

Closed andythsu closed 5 years ago

andythsu commented 5 years ago

My command is test_tags="CreatedBy=\"Foo User\"" az_group_create="az group create --location $location --name $tenantResourceGroupName --tags $test_tags" $az_group_create

it returned "tags": { "CreatedBy": "\"Foo", "User\"": "" }

How do I make it so it returns "tags": { "CreatedBy": "Foo User" }

Please help. Thanks

torosent commented 5 years ago

I tried this pipeline using Azure CLI Plugin 0.9 and Az 2.0.49 and the result was correct

node {
test_tags="CreatedBy=\"Foo User\""
resource_group_name = test"
location = "northeurope"
azureCLI commands: [[exportVariablesString: '', script: "az group create -n ${resource_group_name} -l ${location} --tags ${test_tags}"]], principalCredentialId: 'testid'
}

The result

Running: az group create -n test -l northeurope --tags CreatedBy="Foo User"
{
  "id": "/subscriptions/73a4ea93-d914-424d-9e64/resourceGroups/test",
  "location": "northeurope",
  "managedBy": null,
  "name": "test",
  "properties": {
    "provisioningState": "Succeeded"
  },
  "tags": {
    "CreatedBy": "Foo User"
  }
}
andythsu commented 5 years ago

Thanks! I will close the issue