简体   繁体   English

如何使用常春藤的蚂蚁构建来解决Artifactory中的jar

[英]How to resolve jar from Artifactory using an ant build with ivy

I've managed to cobble together a CI system using Jenkins with an Ant build system that uploads the resultant .jar to Artifactory using the Artifactory plugin. 我已经设法使用Jenkins和一个Ant构建系统拼凑了一个CI系统,该系统使用Artifactory插件将结果.jar上传到Artifactory。

I now need another build which is also Ant to retrieve the latest jar from artifactory using a target in the build.xml. 我现在需要另一个构建,它也是Ant,使用build.xml中的目标从artifactory中检索最新的jar。

I can find lots of articles about how to upload but few about resolving. 我可以找到很多关于如何上传但很少有关于解决的文章。

The closest I have found is http://wiki.jfrog.org/confluence/display/RTF/Working+with+Ivy but this mainly deals with uploading in the vital areas, the screenshots are out of data (or my Artifactory is and I can't update it) and deals with getting ivy or pom files. 我找到的最接近的是http://wiki.jfrog.org/confluence/display/RTF/Working+with+Ivy但这主要涉及在重要区域上传,截图是数据的(或我的Artifactory是和我无法更新它并处理获取常春藤或pom文件。

I'm an Ant/ivy noob so any pointers how to put the target together would be greatly appreciated. 我是一个蚂蚁/常春藤noob所以任何指针如何将目标放在一起将非常感激。

I assume that you already installed ivy . 我假设你已经安装了常春藤

ivysettings.xml ivysettings.xml

You need to define a resolver to artifactory in a file called ivysettings.xml (put it in the root folder, beside the build.xml): 您需要在名为ivysettings.xml的文件中定义一个解析器到artifactory(将它放在build.xml旁边的根文件夹中):

<ivysettings>
        <resolvers>
          <ibiblio name="artifactory" m2compatible="true" root="http://localhost:8080/artifactory/libs-releases"/>
        </resolvers>
</ivysettings>

build.xml build.xml文件

In your build.xml I'd use an inline retrieve (so that you won't have to write an ivy.xml ): 在您的build.xml中,我使用内联检索 (这样您就不必编写ivy.xml ):

<project xmlns:ivy="antlib:org.apache.ivy.ant" name="myName">

    ...

    <target name="retrieve" description="retrieve">
      <ivy:settings /> <!-- needed so that ivysettings.xml is used-->
      <ivy:retrieve organisation="foo" module="bar" inline="true" pattern="lib/[artifact].[ext]"/> 
    </target>
</project>

This will download the artifact into the lib dir. 这会将工件下载到lib目录中。 For organisation and module take the values you find in artifactory. 对于组织和模块,请获取您在artifactory中找到的值。

organisation and module from artifactory 来自神器的组织和模块

In this image from the link you gave, you can see how to get organisation and artifact from artifactory. 在您提供的链接的此图像中,您可以看到如何从神器中获取组织和工件。 It will offer you a dependency declaration box. 它将为您提供依赖声明框。 Just check ivy and take the values from there. 只需检查常春藤并从那里获取值。

在此输入图像描述

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

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