1

作为我正在做的自动化工作的一部分,我需要克隆一个 repo,因为它有一个我需要用于自动化的 json 文件。我已导入posh-git,但无法在git clone <url>其中运行。这是错误:git : The term 'git' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

显然,我已经在源代码管理中添加了我的帐户。所以,我已经完成了 $SourceControl = Get-AzureRmAutomationSourceControl -AutomationAccountName $AutomationAccountName -Name testRepo -ResourceGroupName $ResourceGroupName

然后我在做git clone $SourceControl.RepoUrl

它因上述错误而失败。

任何帮助是极大的赞赏。

4

1 回答 1

1

您无法使用 runbook 中的posh-git模块,因为 runbook 中没有安装 git,因此您将收到错误消息。

请参阅先决条件中的选项 3 :

Git 必须通过 PATH 环境变量安装并可用。通过从 PowerShell 执行 git --version 来检查 git 是否可以从 PowerShell 访问。如果 git 未被识别为命令的名称,请验证您是否安装了 Git。如果没有,请从https://git-scm.com安装 Git 。如果您安装了 Git,请确保 git 的路径在您的 PATH 环境变量中。

您的选择是在存储库中编写所有脚本,配置源代码管理并同步作业,请参阅链接

或者,如果您只想获取 .ps1 文件,可以将其作为 blob 存储在存储帐户中,然后使用Get-AzStorageBlobContent获取它。

于 2020-03-03T08:20:23.147 回答