Azure Devops 在触发新创建的管道时通过休息获取问题触发管道 [英] Azure Devops trigger Pipeline via rest getting issue while triggering newly created pipeline

查看:32
本文介绍了Azure Devops 在触发新创建的管道时通过休息获取问题触发管道的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面的脚本是通过 REST 在 Azure devops 中触发管道,它在现有管道上工作正常,但是当尝试从未运行过的新创建的管道时,它会抛出以下错误.任何帮助或建议将不胜感激.

The below script is to trigger pipeline in Azure devops via REST, Its working fine on an existing pipeline, but when trying on newly created pipeline which has never ran then its throwing below error. Any help or suggestion would be really appreciated.

{"$id":"1","innerException":null,"message":"No pool was specified.\nUnexpected parameter 'pool'","typeName":"Microsoft.Azure.Pipelines.WebApi.PipelineValidationException, Microsoft.Azure.Pipelines.WebApi","typeKey":"PipelineValidationException","errorCode":0,"eventId":3000}

#!/bin/bash

echo "Enter PAT Token"
read -r PAT

echo "Enter Organization name"
read -r OrganizationName

echo "Enter Project ID"
read -r projectId

pipelineId=$(jq -r '.id' PipeOutput.txt)  #Get definition ID from external TXT file

"Trigger_Pipeline=$(curl --write-out "%{http_code}\n" -X POST -L \
-u  :"$PAT" "https://dev.azure.com/""${OrganizationName}""/""${projectId}""/_apis/pipelines/""${pipelineId}""/runs?api-version=6.0-preview.1" \
-H  "Content-Type: application/json" \
-H  "Accept: application/json" \
-d '{
    "resources": {
        "repositories": {
            "self": {
                "refName": "refs/heads/master"
            }
        }
    }
}' --output Triggeroutput.txt --silent)"
echo "Output: $(Trigger_Pipeline)"

推荐答案

我使用新创建的经典管道和 YAML 管道测试了这个 REST API,它在两个管道上都能正常工作.

I tested this REST API with the newly created classic pipeline and YAML pipeline, it works fine on both pipelines.

为了让我们进一步调查此问题,请分享新创建的管道定义的 YAML 文件.

For us to investigate this issue further, please share the YAML file of the newly created pipeline definition.

此外,还请尝试以下步骤:

In addition, please also try with the following steps:

  • 尝试使用其他方法执行 REST API 以查看它是否有效,例如在 Postman 客户端上.
  • 尝试手动触发这个新管道,看看它是否可以工作.
  • 如果手动触发器有效,请再次尝试使用 REST API 触发器.

这篇关于Azure Devops 在触发新创建的管道时通过休息获取问题触发管道的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆