简体   繁体   English

使用wget和Nexus Rest API命名奇数文件

[英]Odd file naming using wget with Nexus Rest API

I have a script that pulls .war artifacts from our nexus repository using wget to pull the artifacts via the Nexus Rest API. 我有一个脚本,可以使用wget从Nexus存储库中提取.war工件,以通过Nexus Rest API提取工件。

The url that I hit with wget is similar to this: 我用wget命中的网址与此类似:

http://our.nexus.net:8081/nexus/service/local/artifact/maven/redirect?g=com.somecompany&a=SomeArtifact&v=1.0.0&r=releases&p=war http://our.nexus.net:8081/nexus/service/local/artifact/maven/redirect?g=com.somecompany&a=SomeArtifact&v=1.0.0&r=releases&p=war

It works fine in our dev environment, and pulls an artifact with the name SomeArtifact-1.0.0.war . 它在我们的开发环境中运行良好,并拉出了名为SomeArtifact-1.0.0.war

However, in our test environment, it pulls the artifact correctly, but gives it the name: 但是,在我们的测试环境中,它可以正确提取工件,但命名为:

redirect?g=com.somecompany&a=SomeArtifact&v=1.0.0&r=releases&p=war

Any ideas as to why it is not renaming it correctly? 关于它为什么不能正确重命名的任何想法?

Here is an example output from wget when it names it wrong. 这是wget命名错误时的输出示例。

--2015-05-11 11:22:12-- http://our.nexus.net:8081/nexus/service/local/artifact/maven/redirect?g=com.somecompany&a=SomeArtifact&v=1.0.0&r=releases&p=war
Resolving our.nexus.net... (IP)
Connecting to our.nexus.net|(IP)|:8081... connected.
HTTP request sent, awaiting response... 307 Temporary Redirect
Location: http://our.nexus.net:8081/nexus/service/local/repositories/releases/content/com/somecompany/SomeArtifact/1.0.0/SomeArtifact-1.0.0.war [following]
--2015-05-11 11:22:12-- http://our.nexus.net:8081/nexus/service/local/repositories/releases/content/com/somecompany/SomeArtifact/1.0.0/SomeArtifact-1.0.0.war
Reusing existing connection to our.nexus.net:8081.
HTTP request sent, awaiting response... 200 OK
Length: 22046212 (21M) [application/java-archive]
Saving to: "/tmp/deploy/redirect?g=com.somecompany&a=SomeArtifact&v=1.0.0&r=releases&p=war"

100%[======================================================>] 22,046,212 56.7M/s in 0.4s

2015-05-11 11:22:12 (56.7 MB/s) - "/tmp/deploy/redirect?g=com.somecompany&a=SomeArtifact&v=1.0.0&r=releases&p=war" saved [22046212/22046212]

And when it does the naming correctly: 当正确命名时:

--2015-05-11 11:22:12-- http://our.nexus.net:8081/nexus/service/local/artifact/maven/redirect?g=com.somecompany&a=SomeArtifact&v=1.0.0&r=releases&p=war
Resolving our.nexus.net... (IP)
Connecting to our.nexus.net|(IP)|:8081... connected.
HTTP request sent, awaiting response... 307 Temporary Redirect
Location: http://our.nexus.net:8081/nexus/service/local/repositories/releases/content/com/somecompany/SomeArtifact/1.0.0/SomeArtifact-1.0.0.war [following]
--2015-05-11 11:22:12-- http://our.nexus.net:8081/nexus/service/local/repositories/releases/content/com/somecompany/SomeArtifact/1.0.0/SomeArtifact-1.0.0.war
Reusing existing connection to our.nexus.net:8081.
HTTP request sent, awaiting response... 200 OK
Length: 22046212 (21M) [application/java-archive]
Saving to: "/tmp/deploy/SomeArtifact-1.0.0.war"

100%[======================================================>] 22,046,212 56.7M/s in 0.4s

2015-05-11 11:22:12 (56.7 MB/s) - "/tmp/deploy/SomeArtifact.1.0.0.war" saved [22046212/22046212]

EDIT: some additional information below. 编辑:下面一些其他信息。

Both the dev and test environment have wget version 1.12. 开发环境和测试环境都具有wget版本1.12。

The dev server, where it works is running RedHat Enterprise Linux OS version 6.4. 工作的开发服务器正在运行RedHat Enterprise Linux OS 6.4版。 The test server, where it does not work is version 6.6. 无法运行的测试服务器是6.6版。

Looks like the problem is the difference in wget setup in RedHat Enterprise Linux OS version 6.4 versus 6.6. 看起来问题出在RedHat Enterprise Linux OS版本6.4与6.6中的wget设置不同。

I ended up just using the -O flag with wget to ensure the file name was what I wanted. 我最终仅在wget中使用-O标志来确保文件名正是我想要的。

wget -O SomeArtifact.1.0.0.war "http://our.nexus.net:8081/nexus/service/local/artifact/maven/redirect?g=com.somecompany&a=SomeArtifact&v=1.0.0&r=releases&p=war"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM