【问题标题】:File upload fail on Nexus from Azure DevOps task "cURL"Azure DevOps 任务“cURL”在 Nexus 上的文件上传失败
【发布时间】:2019-09-09 10:04:10
【问题描述】:

我正在尝试使用“cURL”任务从 Azure DevOps 管道上传文件 txt 或 .nupkg。但文件未上传,并带有 1 条警告消息。

我的配置 -

电流输出 -

预期结果 - 在 Nexus 服务器上上传文件。

请建议我缺少什么!

【问题讨论】:

  • 嗨,最近怎么样?您可以使用在命令行任务中执行的 cUrl api 上传文件吗?随时与我们分享最新状态,以便其他 SO 用户可以帮助您。

标签: curl azure-devops multipartform-data nexus multipart


【解决方案1】:

您可以从日志中看到错误消息:Multiple request required,这是由此任务生成的 API 导致的,不适用于 Nexus。其实在日志的第一行就可以看到它的API这个cUrl任务生成了:

您可以在本地命令中对其进行测试,并且会看到它失败并出现相同的错误“400 Bad request”。此任务无法用于实现上传文件到 Nexus。参考其source code file

curlRunner.arg('-T')
        // arrayify the arg so vsts-task-lib does not try to break args at space
        // this is required for any file input that could potentially contain spaces
        curlRunner.arg([uploadFiles]);

        curlRunner.arg(url);

        if (redirectStderr) {
            curlRunner.arg('--stderr');
            curlRunner.arg('-');
        }

        if (options) {
            curlRunner.line(options);
        }

        if (username || password) {
            var userPassCombo = "";
            if (username) {
                userPassCombo += username;
            }

            userPassCombo += ":";

            if (password) {
                userPassCombo += password;
            }

            curlRunner.arg('-u');
            curlRunner.arg(userPassCombo);
        }

这是任务生成的 API 的 uri。 但是根据 Nexus 官方文档,正确的 cUrl API 应该如下所示:

curl -v -F r={repostory} -F e={extension} -F g={group id} -F a={artifact id} -F v={version} -F p={packaging} -F file={file path} -u {username}:{password} http://localhost:8081/repository/{repostory}/

对比这个正确的Uri,可以看到生成和使用的任务没有完成。这就是您收到警告消息的原因:400 Bad request - cUrl API 正文未完成,它需要更多多个请求。

要将文件上传到 Nexus,您可以使用带有 cUrl API 脚本的命令行任务将文件上传到 Nexus 存储库管理器。

【讨论】:

  • 您好,感谢您的回复,抱歉回复晚了。是的,您是对的,因为 API 请求的格式不正确。现在正如你所说,我正在使用命令行进行尝试。我很困惑我的“组 ID”应该是什么?
  • @DarshanaPatel,它将显示在 Nexus 中的组 ID。你可以自定义它。
  • 我已将组 ID 定义为 org.xx.projectname 但无法正常工作。由于命令没有显示任何错误,但甚至没有给出输出。日志----
  • 是的。它使用代码 200 给出响应。但我无法看到上传到 Nexus 存储库的包。
  • @DarshanaPatel,我认为你最好就此提出新的要求。
猜你喜欢
  • 2020-01-20
  • 1970-01-01
  • 1970-01-01
  • 2022-08-17
  • 1970-01-01
  • 1970-01-01
  • 2020-07-27
  • 2020-11-25
  • 2020-09-28
相关资源
最近更新 更多