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

通过Azure DevOps流水线锁定分支时遇404错误求助

Azure DevOps流水线分支锁定404错误解决方法

问题描述

在Azure DevOps流水线中执行分支锁定命令时,出现以下404错误:

ERROR: The controller for path '/obisvt/_apis' was not found or does not implement IController. Operation returned a 404 status code.

流水线配置代码如下:

trigger: none

appendCommitMessageToRunName: false

pool:
  vmImage: 'ubuntu-latest'

steps:
- task: UsePythonVersion@0
  inputs:
    versionSpec: '3.x'  # Required to use Azure CLI

- task: UseDotNet@2  # Ensures .NET is available if needed
  inputs:
    packageType: 'sdk'
    version: '6.0.302'  

- bash: echo ${AZURE_DEVOPS_CLI_PAT} | az devops login
  env:
    AZURE_DEVOPS_CLI_PAT: $(System.AccessToken)
  displayName: 'Login Azure DevOps Extension'

- script: 
      az repos ref lock --repository "test" --org "https://dev.azure.com/test/project1" --project "OBISVT"  --name "main_test"

解决步骤

1. 修正组织URL格式

--org参数只需填写Azure DevOps组织的根URL,不需要包含项目路径。原命令中的https://dev.azure.com/test/project1错误,应改为https://dev.azure.com/test。

2. 补充分支完整引用路径

--name参数需要指定分支的完整引用格式,即refs/heads/<分支名>。原命令中的main_test应改为refs/heads/main_test。

3. (可选)验证权限

确保流水线使用的System.AccessToken对应的服务账号,对目标仓库拥有Manage branches权限,否则即使命令格式正确,也会因权限不足执行失败。

修改后的正确脚本

将最后一步的script任务替换为:

az repos ref lock --repository "test" --org "https://dev.azure.com/test" --project "OBISVT" --name "refs/heads/main_test"

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.16 17:14:51