通过 REST API 处理 Azure DevOps 管道资源

发布于 2025-01-11 14:43:37 字数 804 浏览 0 评论 0原文

我有一个 Azure DevOps 管道,下面给出了资源部分,

resources:
  repositories:
  - repository: test
    type: git
    name: Hackfest/template
  pipelines:
  - pipeline: Build
    source: mybuild
    branch: main
    # version:  # Latest by default
    trigger:
      branches:
        include:
        - main

我尝试使用 REST API 调用来调用管道。其余 api 调用的主体如下所示

    $body='{
    "definition": {            "id": "3321"        },
     "resources": {
       "pipelines": {
         "Build": {
            "version": "20220304.15",
            "source": "mybuild"
           }
          }
        },
    "sourceBranch": "main"

}'

使用上面的 json 字符串,我可以调用管道构建,但它不会从构建“mybuild”的版本 20220304.15 中选取工件。相反,它采用 mybuild 的最新工件版本并开始构建。

我应该如何修改上面的正文字符串以选择“mybuild”的正确版本?

I have an Azure DevOps pipeline with the resource section is given below

resources:
  repositories:
  - repository: test
    type: git
    name: Hackfest/template
  pipelines:
  - pipeline: Build
    source: mybuild
    branch: main
    # version:  # Latest by default
    trigger:
      branches:
        include:
        - main

I'm trying to invoke the pipeline using a rest api call. The body of the rest api call is given below

    $body='{
    "definition": {            "id": "3321"        },
     "resources": {
       "pipelines": {
         "Build": {
            "version": "20220304.15",
            "source": "mybuild"
           }
          }
        },
    "sourceBranch": "main"

}'

With the above json string I'm able to invoke the pipeline build, but it is not picking the artifacts from version 20220304.15 of the build "mybuild". Rather it is taking the latest artifact version of mybuild and starting the build.

How I should modify the above body string to pick the correct version of the "mybuild"?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你在看孤独的风景 2025-01-18 14:43:37

使用 运行 - 运行管道 这对我有用:

"resources":  {
                  "repositories":  {
                                       "self":  {
                                                    "refName":  "refs/heads/dev"
                                                }
                                   },
                  "pipelines":  {
                                    "Build":  {
                                                         "version":  "Build_202203040100.1"
                                                     }
                                }
              }

With the Runs - Run Pipeline this is worked for me:

"resources":  {
                  "repositories":  {
                                       "self":  {
                                                    "refName":  "refs/heads/dev"
                                                }
                                   },
                  "pipelines":  {
                                    "Build":  {
                                                         "version":  "Build_202203040100.1"
                                                     }
                                }
              }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文