首页 > 解决方案 > Shell Runner 内的 Curl Upload-File

问题描述

我正在尝试从 gitlab-shell-runner 中通过 curl 上传单个文件。

基本上我需要使用这个命令:

curl --user <user:password> --insecure --upload-file <file> https://example.com

显示以下错误:

 Invoke-WebRequest : A positional parameter cannot be found that accepts argument "<user:password>"

我需要做哪些调整才能在 gitlab-ci 中运行它?

我已经尝试使用一个变量来表示地址和不同的引用变体。

先感谢您!

标签: shellcurlgitlab-cigitlab-ci-runner

解决方案


如“在 64 位 Windows 上运行 cURL ”中所述,您正在运行 CmdLet被调用的 ,它在 PowershellInvoke-WebRequest中有一个别名。 首先删除它:curl

Remove-item alias:curl

然后检查您的脚本是否确实调用了实际curl命令(或者您可能需要显式调用它)。

或者:使用Invoke-WebRequest(aliased ' curl') 和Basic $encodedCredentialsheader


推荐阅读