作为我正在做的自动化工作的一部分,我需要克隆一个仓库,因为它有一个我需要用于自动化的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
它失败并显示错误。
非常感谢您的帮助。
答案 0 :(得分:1)
您无法在运行手册中使用posh-git
模块,因为在运行手册中未安装git,因此会出现错误。
请参见Prerequisites中的选项3:
必须安装git,并且可以通过PATH环境变量来使用它。通过从PowerShell执行git --version来检查可从PowerShell访问git。 如果未将git识别为命令名称,请确认您已安装Git。如果没有,请从https://git-scm.com安装Git。如果已安装Git,请确保git的路径在PATH环境变量中。
您的选择是将所有脚本写入存储库中,配置源代码控制并同步作业,请参考link。
或者,如果您只想获取.ps1文件,则可以将其作为Blob存储在存储帐户中,然后使用Get-AzStorageBlobContent
进行获取。