最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

azure devops - Pass parameter to a different-project pipeline via REST api using System.AccessToken - Stack Overflow

programmeradmin4浏览0评论

Project A: deploy.yml

parameters: 
  - name: testparam
    type: string
    default: "default"
    
steps:
  - script: echo hi

Project B: pipeline.yml

jobs:
- job: CallDeploymentPipeline
  pool: Server    
  steps:  
  - task: InvokeRESTAPI@1
    displayName: Call different-project Pipeline
    inputs:
      connectionType: 'connectedServiceName'
      serviceConnection: "myGenericServiceConnectionName"
      method: 'POST'
      headers: '{ "Authorization":"Bearer $(System.AccessToken)", "Content-Type":"application/json" }'
      body: '{
        "resources": { "repositories": { "self": { "refName": "$(Build.SourceBranch)" } } },
        "templateParameters": { "testparam": "test" }
      }'
      urlSuffix: '/ProjectA/_apis/pipelines/<deploy pipeline ID>/runs?api-version=7.1'
      waitForCompletion: 'false'

I get back:

Response: An error was encountered while processing request. Exception: {"$id":"1","innerException":null,"message":"The repository RepoA in project could not be retrieved. Verify the name and credentials being used.","typeName":"Microsoft.TeamFoundation.DistributedTask.Pipelines.ResourceValidationException, Microsoft.TeamFoundation.DistributedTask.WebApi","typeKey":"ResourceValidationException","errorCode":0,"eventId":3000} Exception Message: The remote server returned an error: (500) Internal Server Error. (type WebException)

This works if any one of the following are changed:

  1. No parameter is passed (i.e. this line is removed "templateParameters": { "testparam": "test" })
  2. OR PAT is used vs System.AccessToken
  3. OR Pipelines are placed in the same project

Yes, I have followed the docs and set Limit job authorization scope to current project for non-release pipelines OFF for the and project.

Yes, Project Collection Build Service has Read access to my repo and Queue Build permission to deploy pipeline.

Run Pipeline api docs

Am I doing anything wrong or is this a bug?

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论