问题描述
我正在使用 Power Platform Build Tools 构建我的第一个管道。我正在尝试将 Dynamics 模型驱动的应用程序导出到存储库。我的命令行脚本出现错误。以下是错误日志:
2021-01-21T08:48:04.6191345Z ##[section]Starting: Command Line Script
2021-01-21T08:48:04.6292483Z
==============================================================================
2021-01-21T08:48:04.6292831Z Task : Command line
2021-01-21T08:48:04.6293131Z Description : Run a command line script using Bash on Linux and macOS
and cmd.exe on Windows
2021-01-21T08:48:04.6293422Z Version : 2.178.0
2021-01-21T08:48:04.6293630Z Author : Microsoft Corporation
2021-01-21T08:48:04.6293952Z Help :
https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
2021-01-21T08:48:04.6294293Z
==============================================================================
2021-01-21T08:48:05.7216764Z error: pathspec 'master' did not match any file(s) kNown to git
2021-01-21T08:48:05.7217182Z Generating script.
2021-01-21T08:48:05.7217463Z ========================== Starting Command Output
===========================
2021-01-21T08:48:05.7217952Z ##[command]"C:\windows\system32\cmd.exe" /D /E:ON /V:OFF /S /C "CALL
"D:\a\_temp\93c0ac5e-da28-4265-b4d0-4326b5f38209.cmd""
2021-01-21T08:48:05.7218457Z commit all changes
2021-01-21T08:48:05.7218642Z push code to new repo
2021-01-21T08:48:05.7226781Z fatal: pathspec '-' did not match any files
2021-01-21T08:48:05.7227220Z error: pathspec 'export"' did not match any file(s) kNown to git
2021-01-21T08:48:06.2395991Z git: 'bearer' is not a git command. See 'git --help'.
2021-01-21T08:48:06.2983259Z ##[error]Cmd.exe exited with code '1'.
2021-01-21T08:48:06.3323471Z ##[section]Finishing: Command Line Script
基于这个输出,我不知道缺少什么。
解决方法
根据你的截图,你的默认分支是“main”,而不是“master”。
master
与 git 已知的任何分支都不匹配,因此任务失败。
此外,您需要使用 origin/{branch}
而不是 {branch}
。由于分支是远程分支。
Azure DevOps Pipeline 中的命令行脚本错误
这可能是因为你的 git 命令有错误的语法。
根据你提供的图片,我们可以知道你使用的git命令行是:
这不是添加所有文件的正确语法,这也是您收到错误的原因:
fatal: pathspec '-' did not match any files
如果我使用相同的语法 git add —— all
,我会得到相同的错误信息。
要解决此错误,请尝试使用以下正确的语法:
git add --all
此外,我们不能将 AUTHORIZATION:BEARER 与 $(system.AccessToken)
一起使用,您需要使用 Authorization: Basic with Base64-encode:
请查看this thread了解更多详情。
这就是您收到错误 git: 'bearer' is not a git command.
的原因。
为了解决这个问题,你可以直接使用带有 PAT 的 git 命令行来推送文件:
git push https://<Your PAT>@dev.azure.com/<YourOrganization>/<YourProject>/_git/MyTestProject HEAD:master
另外,简说的是另一个问题。