使用通配符的 Jenkins wget 神器

Jenkins wget artifact using wildcard

我正在尝试使用传递 -A 参数和通配符“*.jar”的 wget 下载 jar 工件,但是 jenkins 没有下载 jar 文件。相同的命令适用于非詹金斯 url。有没有人和詹金斯一起工作过。非常感谢您的意见。

wget --no-check-certificate --auth-no-challenge -A "*.jar" -r -l 1 -nd "https://jenkins.xxxx.com/job/xxxx/6/artifact/target/"
--2015-11-02 06:24:36--  https://jenkins.xxxx.com/job/xxxx/6/artifact/target/
Resolving jenkins.xxxx.com... 1.1.1.1
Connecting to jenkins.xxxx.com|1.1.1.1|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://jenkins.xxxx.com/job/xxxx/6/artifact/target/ [following]
--2015-11-02 06:24:37--  https://jenkins.xxxx.com/job/xxxx/6/artifact/target/
Reusing existing connection to jenkins.xxxx.com:443.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: `index.html'
[ <=>                                                                                                                                                ] 12,420      --.-K/s   in 0s
2015-11-02 06:24:37 (592 MB/s) - `index.html' saved [12420]

Loading robots.txt; please ignore errors.
--2015-11-02 06:24:37--  https://jenkins.xxxx.com/robots.txt
Connecting to jenkins.xxxx.com|1.1.1.1|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2015-11-02 06:24:37 ERROR 404: Not Found.

Removing index.html since it should be rejected.

FINISHED --2015-11-02 06:24:37--
Downloaded: 1 files, 12K in 0s (592 MB/s)

更新: 重新审视这个,我意识到 Jenkins 服务器 实际上无法提供服务 its robots.txt file:

Loading robots.txt; please ignore errors.
--2015-11-02 06:24:37--  https://jenkins.xxxx.com/robots.txt
Connecting to jenkins.xxxx.com|1.1.1.1|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2015-11-02 06:24:37 ERROR 404: Not Found.

出现此 404 错误后,wget 解释说它不会保留已下载的 index.html

Removing index.html since it should be rejected.

wget manual 中快速查找拒绝结果:

(...) the accept/reject lists are matched twice against downloaded files: once against the URL’s filename portion, to determine if the file should be downloaded in the first place; then, after it has been accepted and successfully downloaded, the local file’s name is also checked against the accept/reject lists to see if it should be removed. The rationale was that, since ‘.htm’ and ‘.html’ files are always downloaded regardless of accept/reject rules, they should be removed after being downloaded and scanned for links, if they did match the accept/reject lists.

这意味着您最初请求的 URL 已被下载并扫描链接,但 none 的链接匹配 *.jar,因此 none 被检索。然后,原来请求的index.html被删除了,因为它的名字也不匹配*.jar

看起来实际上没有指向您要在此页面上直接下载的 .jar 个工件的链接。具有讽刺意味的是,这意味着我最终建议与以前相同 - 尝试使用 -l2 而不是 -l1 将子目录递归增加一级。正如我在之前的回答中所说,我确实在本地 Jenkins 安装上尝试过这个,我实际上需要 -l2 从那里下载一个工件 (但确切的级别可能取决于关于项目设置和文件夹结构)。请尝试:

wget --no-check-certificate --auth-no-challenge -A "*.jar" -r -l2 -nd "https://jenkins.xxxx.com/job/xxxx/6/artifact/target/"