curl - Azure DevOps 任务“cURL”在 Nexus 上的文件上传失败
问题描述
我正在尝试使用“cURL”任务从 Azure DevOps 管道上传文件 txt 或 .nupkg。但该文件未上传,并带有 1 条警告消息。
电流输出 -
预期结果 - 在 Nexus 服务器上上传文件。
请提出我所缺少的!
解决方案
正如您从日志中看到的错误消息:Multiple request required
,这是由此任务生成的 API 引起的,不适用于 Nexus。其实在日志的第一行,就可以看到它的这个cUrl任务生成的API:
您可以在本地命令中对其进行测试,并且会看到它失败并出现相同的错误“ 400 Bad request
”。此任务无法用于实现上传文件到 Nexus。参考其源代码文件:
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 存储库管理器。
推荐阅读
- javascript - 如何在 kotlin 中的 js 数组上使用 push() 或 pop()?
- bash - Azure CLI 解析
- python - Python中的加载栏崩溃
- javascript - (模态)循环组件
- python - 如何使用循环填充字典
- angular - Angular - JSONP 注入脚本未调用回调
- php - 致命错误:在第 1943 行的 C:\wamp\www\Scaffolding\PHPMailer-master\src\PHPMailer.php 中找不到类 'PHPMailer\PHPMailer\Exception'
- c - 验证输入数据。在函数内部或外部,最佳方式
- jquery - 为什么我不能将带有表单的 .load() Jquery 发送到加载的页面?
- javascript - javascript 阶乘函数得到 RangeError