mystack
mystack

Reputation: 5482

Handle Azure Devops pipeline resource over rest api

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"?

Upvotes: 1

Views: 1093

Answers (1)

Shayki Abramczyk
Shayki Abramczyk

Reputation: 41545

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

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

Upvotes: 2

Related Questions