我如何检索的Nexus通过卷曲使用他们的REST API的神器校验? [英] How do I retrieve an artifact checksum from Nexus using their rest api via curl?

查看:464
本文介绍了我如何检索的Nexus通过卷曲使用他们的REST API的神器校验?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想验证我从下载的Nexus文物的校验和。我可以抓取工件,并下载和检查其的md5sum或sha1sum分别,但我需要检查这对Nexus的实际金额,所以我可以证实他们是正确的。

这是我用抢文件命令从的Nexus:

 卷曲-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'

通过<一个href=\"http://nexus.xwiki.org/nexus/nexus-indexer-lucene-plugin/default/docs/path__lucene_search.html\" rel=\"nofollow\">http://nexus.xwiki.org/nexus/nexus-indexer-lucene-plugin/default/docs/path__lucene_search.html,这样看来,我还可以搜索SHA1总和,但是当我做&放大器; SHA1我得到什么额外的或者SHA1 =(总和),没有被上拉,即使我省略了上述所有选项

这工作,但它关系到一个具体的战争,我们需要最新的(显然):

<$p$p><$c$c>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

这是可能的,我在正确的轨道上吗?


解决方案

您可以直接读取文件或使用Nexus API以编程方式检索。

以下网址:

<$p$p><$c$c>http://localhost:8081/nexus/service/local/artifact/maven/resolve?g=log4j&a=log4j&v=1.2.9&r=central

返回以下结果:

 &LT;神器分辨率&GT;
  &lt;数据&GT;
    &LT; presentLocally&GT;真&LT; / presentLocally&GT;
    &LT;&的groupId GT;的log4j&LT; /的groupId&GT;
    &LT;&的artifactId GT;的log4j&LT; / artifactId的&GT;
    &LT;&版GT; 1.2.9&LT; /版本&GT;
    &LT;扩展名为GT;&罐子LT; /展期&GT;
    &LT;&快照GT假LT; /快照&GT;
    &所述; snapshotBuildNumber大于0&下; / snapshotBuildNumber&GT;
    &所述; snapshotTimeStamp大于0&下; / snapshotTimeStamp&GT;
    &LT;&SHA1 GT; 55856d711ab8b88f8c7b04fd85ff1643ffbfde7c&LT; / SHA1&GT;
    &LT; repositoryPath&GT; /log4j/log4j/1.2.9/log4j-1.2.9.jar< / repositoryPath&GT;
  &LT; /数据&GT;
&LT; /神器分辨率&GT;

的xmllint命令可用于解析出的SHA1校验和值如下:

  $卷曲-s \"http://localhost:8081/nexus/service/local/artifact/maven/resolve?g=log4j&a=log4j&v=1.2.9&r=central\" | xmllint --xpath/// SHA1 /文() - 
55856d711ab8b88f8c7b04fd85ff1643ffbfde7c

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.

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'

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?

解决方案

You can either fetch the file directly or use the Nexus API to retrieve it programmatically.

The following URL:

http://localhost:8081/nexus/service/local/artifact/maven/resolve?g=log4j&a=log4j&v=1.2.9&r=central

Returns the following result:

<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>

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

这篇关于我如何检索的Nexus通过卷曲使用他们的REST API的神器校验?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆