Azure / azure-cli-extensions

Public Repository for Extensions of Azure CLI.
https://docs.microsoft.com/en-us/cli/azure
MIT License
381 stars 1.2k forks source link

How to supply parameters in az pipelines run? #2974

Open sdebruyn opened 3 years ago

sdebruyn commented 3 years ago

The command az pipelines run does not have a documented way on how to supply the parameters that the pipeline requires. Using the --variables option to supply parameters does not work.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

ghost commented 3 years ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @narula0781, @ashishonce, @romil07.

Issue Details
The command `az pipelines run` does not have a documented way on how to supply the parameters that the pipeline requires. Using the `--variables` option to supply parameters does not work. --- #### Document Details ⚠ *Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.* * ID: 2a2123ca-5408-8f93-6f5c-93fe74684523 * Version Independent ID: 7a03fe73-da7f-9b5a-38e7-ef51d85d49fd * Content: [az pipelines](https://docs.microsoft.com/en-us/cli/azure/ext/azure-devops/pipelines?view=azure-cli-latest) * Content Source: [latest/docs-ref-autogen/ext/azure-devops/pipelines.yml](https://github.com/MicrosoftDocs/azure-docs-cli/blob/master/latest/docs-ref-autogen/ext/azure-devops/pipelines.yml) * GitHub Login: @rloutlaw * Microsoft Alias: **routlaw**
Author: sdebruyn
Assignees: -
Labels: `DevOps`, `Pipelines`, `Service Attention`, `needs-triage`, `question`
Milestone: -
yonzhan commented 3 years ago

pipelines

dylanberry commented 3 years ago

Any updates on this?

This command:

az pipelines run --organization "https://dev.azure.com/organization/" `
    --project "project" `
    --name "Pipeline" `
    --open `
    --variables foo=bar --debug

Throws this error:

cli.azure.cli.core.azclierror: Could not queue the build because there were validation errors or warnings.

Digging into the debug output, I see the parameter being passed:

azext_devops.devops_sdk.client: POST https://dev.azure.com/organization/project/_apis/build/Builds
azext_devops.devops_sdk.client: Request content: {'definition': {'id': 25}, 'parameters': "{'foo': 'bar'}"}
dylanberry commented 3 years ago

Any updates on this?

This command:

az pipelines run --organization "https://dev.azure.com/organization/" `
    --project "project" `
    --name "Pipeline" `
    --open `
    --variables foo=bar --debug

Throws this error:

cli.azure.cli.core.azclierror: Could not queue the build because there were validation errors or warnings.

Digging into the debug output, I see the parameter being passed:

azext_devops.devops_sdk.client: POST https://dev.azure.com/organization/project/_apis/build/Builds
azext_devops.devops_sdk.client: Request content: {'definition': {'id': 25}, 'parameters': "{'foo': 'bar'}"}

It looks like pipelines run is mapped to the incorrect rest endpoint (build/Builds) and needs to accept templateParameters to pass values to the yaml pipeline. This works:

POST https://dev.azure.com/organization/project/_apis/pipelines/25/runs?api-version=6.0-preview.1
Content-Type: application/json
X-VSS-ForceMsaPassThrough: true
Authorization: Basic <PAT>
{
    "templateParameters": {"foo": "bar"}
}
mimiz commented 3 years ago

Hi, Is there a plan to fix this issue on az pipelines run --variables ? as the workaround with CURL is not acceptable in my case. Regards

Rémi

yonzhan commented 3 years ago

@narula0781, @ashishonce, @romil07, any update?

dylanberry commented 3 years ago

Hi, Is there a plan to fix this issue on az pipelines run --variables ? as the workaround with CURL is not acceptable in my case. Regards

Rémi

Can you use PowerShell or something else? Always best to try and work around these issues rather than wait for a fix.

superff commented 2 years ago

Is there a plan to fix this bug? it is blocking us

az pipelines run --variables ? our pipeline failed to take the vars

--variables env=dev

# Used for triggering pipeline programmatically via DevOps CLI
variables:
  - name: env
 stages:
  - template: /run.yaml
    parameters:
      env: ${{ variables.env }}
andcip commented 1 year ago

Is there a plan to fix this bug? Same error on Mac Os with az version: azure-cli 2.47.0 core 2.47.0 telemetry 1.0.8 Extensions: azure-devops 0.26.0 Dependencies: msal 1.20.0 azure-mgmt-resource 22.0.0

Python (Darwin) 3.10.11 [Clang 14.0.0 (clang-1400.0.29.202)]

rgadge commented 11 months ago

I am trying to pass on a list of variables using the approach and it still fails with the following: cli.azure.cli.core.azclierror: Could not queue the build because there were validation errors or warnings. Is there a plan to fix this in upcoming versions of a workaround for my situation?