You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

通过REST API跨项目传参调用Pipeline遇500错误求助

跨项目Pipeline通过REST API传递参数时的权限问题

我尝试通过REST API,使用System.AccessToken将参数传递给跨项目的Pipeline,具体配置如下:

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'

执行错误信息

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)

可正常运行的修改方案

以下任一修改均可让Pipeline正常运行:

  • 移除"templateParameters": { "testparam": "test" }行,不传递参数
  • 使用PAT替代System.AccessToken
  • 将两个Pipeline迁移至同一项目中

已完成的权限配置

已将组织和项目层级的“限制非发布管道的作业授权范围为当前项目”设置为OFF,且Project Collection Build Service账号已拥有RepoA的读取权限和Project A中部署Pipeline的队列构建权限。

疑问

按照Run Pipeline API文档操作,请问当前操作是否存在错误,还是这是一个已知bug?

内容的提问来源于stack exchange,提问作者Rachel

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.14 07:53:18