首页 > 解决方案 > 使用控制台将 git clone 存储库转换为 powershell azure 函数

问题描述

git clone在 Azure 函数 powershell 7.0 上运行命令的正确 sintaxis 是什么?

我正在尝试:git clone <repo https>

并在最后添加路径git clone <repo https> /.

我收到以下错误消息:

`Command 'starter.cmd git clone https ...' was aborted due to no output nor CPU activity for 60 seconds. You can increase the SCM_COMMAND_IDLE_TIMEOUT app setting (or WEBJOBS_IDLE_TIMEOUT if this is a WebJob) if needed.`

*更新:

也试过了git clone https://username:password@github.com/username/repository.git

克隆到 ''... 致命:无法访问 'https://github.com//.git/':URL 使用错误/非法格式或缺少 URL

我还没有找到任何关于这方面的文档……这有可能吗?

标签: azurepowershellazure-functions

解决方案


我首先要问您这样做是为了达到什么目的,因为这有点奇怪,并且可能有更好的方法将存储库克隆为管道的一部分并使用您的函数发布内容。

如果你真的必须走这条路,我会考虑用 Invoke-RestMethod/Invoke-WebRequest 下载 repo/branch 内容,然后解压到底层目录结构。

Invoke-WebRequest -Uri 'https://github.com/$owner/$repo/archive/$branch.zip' -OutFile '$repo.zip'

或使用像 Matthias 在此响应中指出的 .NET 方法: https ://stackoverflow.com/a/48547954/12040634


推荐阅读