如何通过 curl 使用他们的 rest api 从 Nexus 检索工件校验和? [英] How do I retrieve an artifact checksum from Nexus using their rest api via curl?
问题描述
我正在尝试验证我从 Nexus 下载的工件的校验和.我可以获取工件并下载它们并检查它们的 md5sum 或 sha1sum,但我需要将其与 Nexus 的实际总和进行核对,以便验证它们是否正确.
I am trying to verify the checksum of the artifacts I am downloading from Nexus. I can grab the artifact and download them and check their md5sum or sha1sum, but I need to check this against the actual sum from Nexus so I can verify they are correct.
这是我用来从 Nexus 抓取文件的命令:
This is the command I'm using to grab files from Nexus:
curl -v -L -o /mylocation/artifact.war -u 'myuser:mypass' --get 'http://ournexus.com/service/local/artifact/maven/content?g=com.ours.stuff&a=our-service-war&v=LATEST&r=snapshots&p=war'
通过 http://nexus.xwiki.org/nexus/nexus-indexer-lucene-plugin/default/docs/path__lucene_search.html,看来我也可以搜索 sha1 总和,但是当我做 &sha1 时,我没有得到任何额外的或sha1=(sum), 什么也拉不起来,即使我省略了上面所有的选项.
Via http://nexus.xwiki.org/nexus/nexus-indexer-lucene-plugin/default/docs/path__lucene_search.html, it would appear that I can also search for the sha1 sum, but when I do &sha1 I get nothing extra or sha1=(sum), nothing is pulled up, even if I omit all the above options.
这行得通,但它涉及特定的战争,我们需要最新的(显然):
This works, but it goes to a specific war, and we need the latest (obviously):
http://ournexus.com/service/local/repositories/snapshots/content/com/ours/stuff/ourapp/1.0.0-SNAPSHOT/ourapp-1.0.0-20140730.173704-88.war.sha1
这可能吗,我在正确的轨道上吗?
Is this possible, am I on the right track?
推荐答案
您可以直接获取文件,也可以使用 Nexus API 以编程方式获取文件.
You can either fetch the file directly or use the Nexus API to retrieve it programmatically.
以下网址:
http://localhost:8081/nexus/service/local/artifact/maven/resolve?g=log4j&a=log4j&v=1.2.9&r=central
返回以下结果:
<artifact-resolution>
<data>
<presentLocally>true</presentLocally>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.9</version>
<extension>jar</extension>
<snapshot>false</snapshot>
<snapshotBuildNumber>0</snapshotBuildNumber>
<snapshotTimeStamp>0</snapshotTimeStamp>
<sha1>55856d711ab8b88f8c7b04fd85ff1643ffbfde7c</sha1>
<repositoryPath>/log4j/log4j/1.2.9/log4j-1.2.9.jar</repositoryPath>
</data>
</artifact-resolution>
可以使用xmllint命令解析出sha1校验和值如下:
The xmllint command can be used to parse out the sha1 checksum value as follows:
$ curl -s "http://localhost:8081/nexus/service/local/artifact/maven/resolve?g=log4j&a=log4j&v=1.2.9&r=central" | xmllint --xpath "///sha1/text()" -
55856d711ab8b88f8c7b04fd85ff1643ffbfde7c
这篇关于如何通过 curl 使用他们的 rest api 从 Nexus 检索工件校验和?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!