Azure DevOps流水线报错:.gitmodules无PropWorx.Portal子模块URL
问题
我有一个Angular 12 Web应用,本地构建运行正常,代码托管在Azure DevOps Git仓库。尝试通过CI/CD发布到Azure静态Web应用时,关联仓库后系统自动生成了流水线YAML,但运行时出现报错。
自动生成的流水线YAML:
name: Azure Static Web Apps CI/CD pr: branches: include: - Angular13-2023-03 trigger: branches: include: - Angular13-2023-03 jobs: - job: build_and_deploy_job displayName: Build and Deploy Job condition: or(eq(variables['Build.Reason'], 'Manual'),or(eq(variables['Build.Reason'], 'PullRequest'),eq(variables['Build.Reason'], 'IndividualCI'))) pool: vmImage: ubuntu-latest variables: - group: Azure-Static-Web-Apps-yellow-mushroom-05b59cd03-variable-group steps: - checkout: self submodules: true - task: AzureStaticWebApp@0 inputs: azure_static_web_apps_api_token: $(AZURE_STATIC_WEB_APPS_API_TOKEN_YELLOW_MUSHROOM_05B59CD03) app_location: "/" # App source code path api_location: "" # Api source code path - optional output_location: "" # Built app content directory - optional
流水线报错信息:
fatal: No url found for submodule path 'PropWorx.Portal' in .gitmodules ##[error]Git submodule update failed with exit code: 128
注:PropWorx.Portal是Azure DevOps上的另一个项目,当前项目中不存在.gitmodules文件。
解决方案
问题原因
流水线YAML里的checkout: self配置了submodules: true,会触发Git拉取所有子模块。即便本地没看到.gitmodules,仓库可能存在子模块残留记录(比如.git/config里的配置、或历史中曾添加后删除子模块但未清理),导致构建代理尝试拉取不存在的PropWorx.Portal子模块。
修复方法
修改流水线配置
直接修改YAML中的checkout步骤,将submodules: true改为submodules: false,或者删除该参数(默认值即为false):- checkout: self submodules: false清理仓库子模块残留(若修改流水线后仍报错)
在本地仓库执行以下命令清理残留的子模块记录:git submodule deinit -f . rm -rf .git/modules git rm -f PropWorx.Portal提交并推送这些修改到Azure DevOps仓库即可。
内容的提问来源于stack exchange,提问作者Fabricio Rodriguez
相关产品推荐
相关产品推荐

