Search code examples
azure-devopsazure-pipelinesazure-cliazure-pipelines-yaml

How do I get past "Could not queue the build because there were validation errors or warnings." while automating pipeline creation using az-cli


I am trying to automate rsync pipeline creation using az-cli. This is the command I am running from a local clone of my repository:

az pipelines create --name my_pipeline --yml-path azure-pipeline.yml --project my_project --repository my_repo --repository-type tfsgit

The pipeline is created but it is not able to queue it. Here are the details from the --debug switch. Am I missing something? The expected output was to not only create the pipeline but also run it.

**WARNING: This command is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus

WARNING: cli.azext_devops.dev.pipelines.pipeline_create: Successfully created a pipeline with Name: my_pipeline, Id: 2019.**

DEBUG: msrest.exceptions: Could not queue the build because there were validation errors or warnings.

DEBUG: cli.azext_devops.dev.common.exception_handler: handling vsts service error

DEBUG: cli.azure.cli.core.util: azure.cli.core.util.handle_exception is called with an exception:

DEBUG: cli.azure.cli.core.util: Traceback (most recent call last):

File "/usr/lib64/az/lib/python3.6/site-packages/azure/cli/core/commands/init.py", line 691, in _run_job

result = cmd_copy(params)

File "/usr/lib64/az/lib/python3.6/site-packages/azure/cli/core/commands/init.py", line 328, in call

*return self.handler(*args, *kwargs)

File "/usr/lib64/az/lib/python3.6/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler

*return op(*command_args)

File "/home/user/.azure/cliextensions/azure-devops/azext_devops/dev/pipelines/pipeline_create.py", line 155, in pipeline_create project=project)

File "/home/user/.azure/cliextensions/azure-devops/azext_devops/devops_sdk/v5_1/build/build_client.py", line 337, in queue_build content=content)

File "/home/user/.azure/cliextensions/azure-devops/azext_devops/devops_sdk/client.py", line 90, in _send

response = self._send_request(request=request, headers=headers, content=content, media_type=media_type)

File "/home/user/.azure/cliextensions/azure-devops/azext_devops/devops_sdk/client.py", line 54, in _send_request

self._handle_error(request, response)

File "/home/user/.azure/cliextensions/azure-devops/azext_devops/devops_sdk/client.py", line 233, in _handle_error

raise AzureDevOpsServiceError(wrapped_exception)

azext_devops.devops_sdk.exceptions.AzureDevOpsServiceError: Could not queue the build because there were validation errors or warnings.

During handling of the above exception, another exception occurred: Traceback (most recent call last):

File "/usr/lib64/az/lib/python3.6/site-packages/knack/cli.py", line 231, in invoke

cmd_result = self.invocation.execute(args)

File "/usr/lib64/az/lib/python3.6/site-packages/azure/cli/core/commands/init.py", line 657, in execute

raise ex

File "/usr/lib64/az/lib/python3.6/site-packages/azure/cli/core/commands/init.py", line 720, in _run_jobs_serially

results.append(self._run_job(expanded_arg, cmd_copy))

File "/usr/lib64/az/lib/python3.6/site-packages/azure/cli/core/commands/init.py", line 712, in _run_job

return cmd_copy.exception_handler(ex)

File "/home/user/.azure/cliextensions/azure-devops/azext_devops/dev/common/exception_handler.py", line 18, in azure_devops_exception_handler

raise CLIError(ex)

knack.util.CLIError: Could not queue the build because there were validation errors or warnings.

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

ERROR: az_command_data_logger: Could not queue the build because there were validation errors or warnings.

DEBUG: cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x7fe2e4a682f0>]

INFO: az_command_data_logger: exit code: 1

INFO: cli.main: Command ran in 2.552 seconds (init: 0.200, invoke: 2.352)

INFO: telemetry.save: Save telemetry record of length 3257 in cache

WARNING: telemetry.check: Negative: The /home/user/.azure/telemetry.txt was modified at 2022-04-07 14:29:35.737231, which in less than 600.000000 s

Additional information: I am setting the AZURE_DEVOPS_EXT_PAT env variable to authenticate and use az-cli commands.


Solution

  • The error message says it all, it can't queue the build because there are errors in the YAML.

    It created pipeline 2019, you need to review the YAML and correct the validation errors before it'll run:

    1. Open a browser and navigate to https://dev.azure.com/<your-organization-name>/<your-project-name>/_build?definitionId=2019

    2. Click on the Edit button

    3. In the elipsis context menu, select validate:

    The error message about the invalid syntax will be shown in a dialog box.

    Alternatively, the Azure DevOps REST API exposes an endpoint to do the same: