Hudson 插件未将所有工件发布到 Artifactory

发布于 2024-10-16 10:01:59 字数 5216 浏览 2 评论 0原文

我有一个小型 Java 项目设置,可以通过 Hudson 服务器持续构建。我想将构建工件作为构建后步骤发布到 Artifactory 服务器,因此,自然地,我使用 Hudson-Artifactory 插件来促进这一点。本地发布似乎工作得很好 - 它按预期发布了两个工件(都是 .jar 文件)和已解析的 ivy.xml 文件。然而,当我请求在 Hudson 服务器上进行构建时,我的两个工件中仅发布了一个。

该构建创建了以下工件:

ftpSvc.jar
ftpSvc-lib.jar

我的 ivy.xml 文件如下所示:

<?xml version="1.0" encoding="ISO-8859-1"?>
<ivy-module version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd">

    <info organisation="esf"
          status="integration"
          module="ftpSvc"
          revision="SNAPSHOT" />

    <publications>
        <artifact name="ftpSvc" ext="jar"/>
        <artifact name="ftpSvc-lib" ext="jar" type="lib" />
    </publications>

    <!--list the dependencies of this project-->
    <dependencies>
        <dependency org="commons-net" name="commons-net" rev="1.3.0" />
    </dependencies>
</ivy-module>

这两个工件在 部分中清楚地标出。我的 build.xml 文件中的构建目标如下所示:

<target name="publish_local" description="publish artifacts locally">
    <echo>organisation: ${ivy.organisation}</echo>
    <echo>module: ${ivy.module}</echo>
    <echo>status: ${ivy.status}</echo>
    <echo>revision: ${ivy.revision}</echo>
    <echo>local dir: ${ivy.default.ivy.user.dir}</echo>

    <ivy:publish
        resolver="local"
        update="true"
        verwrite="true"
        srcivypattern="${bundle.jar.dir}/ivy.xml"
        artifactspattern="${bundle.jar.dir}/[artifact].[ext]" />
</target>

artifactspattern 从构建目录中获取所有已定义的工件 - 这里没有什么特别的。最后,我的 ivysettings.xml 文件中的解析器链如下所示(服务器名称已更改以保护无辜者):

<resolvers>
    <chain name="main">
        <ibiblio name="main" m2compatible="true" root="http://my.server.employer.com:8080/artifactory/repo" />

        <filesystem name="local"> 
            <ivy pattern="${ivy.default.ivy.user.dir}/local/[organisation]/[module]/[revision]/ivy-[revision].xml" />
            <artifact pattern="${ivy.default.ivy.user.dir}/local/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" /> 
        </filesystem>
    </chain>
</resolvers>

这都是相当常规的内容,并且如上所述,本地发布工作正常。下面是我通过 Eclipse 构建时的控制台输出:

publish_local:
     [echo] organisation: esf
     [echo] module: ftpSvc
     [echo] status: integration
     [echo] revision: SNAPSHOT
     [echo] local dir: C:\Users\myusername\.ivy2
[ivy:publish] :: publishing :: esf#ftpSvc
[ivy:publish]   published ftpSvc to C:\Users\myusername\.ivy2/local/esf/ftpSvc/SNAPSHOT/ftpSvc-SNAPSHOT.jar
[ivy:publish]   published ftpSvc-lib to C:\Users\myusername\.ivy2/local/esf/ftpSvc/SNAPSHOT/ftpSvc-lib-SNAPSHOT.jar
[ivy:publish]   published ivy to C:\Users\myusername\.ivy2/local/esf/ftpSvc/SNAPSHOT/ivy-SNAPSHOT.xml

.jar 文件和已解析的 ivy.xml 文件都按预期发布。在我的 Hudson 服务器上,我已经这样配置了 Artifactory 配置设置(再次,一些细节已更改以掩盖我真正的超级英雄身份):

Artifactory 服务器:http://my.server.employer.com:8080 /artifactory
目标存储库:目标存储库
Ivy 模式:[组织]/[模块]/[修订版]ivy-[修订版].xml
Artifact 模式:"[organization]/[module]/[revision]/[artifact]-[revision].[ext]"

如您所见,Ivy 和 Artifact 模式完全一致与我的 ivysettings.xml 文件中的本地解析器中的模式相同。因此,当构建在 Hudson 服务器上运行时,我希望将完全相同的工件发布到我的 Artifactory 服务器上。

让我们看一下我的 Hudson 服务器上最新版本的控制台输出:

publish_local:
     [echo] organisation: esf
     [echo] module: ftpSvc
     [echo] status: integration
     [echo] revision: SNAPSHOT
     [echo] local dir: /usr/share/tomcat6/.ivy2
[ivy:publish] :: publishing :: esf#ftpSvc
Collecting Module information for module: ftpSvc
Module location: /usr/share/tomcat6/.hudson/jobs/ftpSvc-ivy/workspace/trunk/out/jars/ftpSvc.jar
[ivy:publish]   published ftpSvc to /usr/share/tomcat6/.ivy2/local/esf/ftpSvc/SNAPSHOT/ftpSvc-SNAPSHOT.jar
Collecting Module information for module: ftpSvc
Module location: /usr/share/tomcat6/.hudson/jobs/ftpSvc-ivy/workspace/trunk/out/jars/ftpSvc-lib.jar
[ivy:publish]   published ftpSvc-lib to /usr/share/tomcat6/.ivy2/local/esf/ftpSvc/SNAPSHOT/ftpSvc-lib-SNAPSHOT.jar
Collecting Module information for module: ftpSvc
Module location: /tmp/ivy2450884590736960955.xml
[ivy:publish]   published ivy to /usr/share/tomcat6/.ivy2/local/esf/ftpSvc/SNAPSHOT/ivy-SNAPSHOT.xml
Build finished triggered
Deploying artifact: http://my.server.employer.com:8080/artifactory/target-repository/esf/ftpSvc/SNAPSHOT/ftpSvc-SNAPSHOT.jar
Deploying artifact: http://my.server.employer.com:8080/artifactory/target-repository/esf/ftpSvc/SNAPSHOT/ftpSvc-SNAPSHOT.xml
Deploying build info to: http://my.server.employer.com.com:8080/artifactory/api/build

Dubya' Tee Eff!?再次,本地发布似乎工作得很好,将 jar 和 ivy.xml 文件发布到 Hudson 服务器上的 local/esf/ftpSvc/SNAPSHOT/ 目录。另一方面,Artifactory 插件则完全错误。它不仅无法发布两个 jar 之一,而且还错误地重命名了 ivy.xml 文件。

有没有 Hudson/Ivy/Artifactory 专家可以解释一下这里发生的事情?我有多个项目表现出完全相同的行为。对于解决此问题的任何和所有帮助,我们将不胜感激。

I've got a small Java project setup to build continuously through a Hudson server. I'd like to publish the build artifacts to an Artifactory server as a post-build step so, naturally, I'm using the Hudson-Artifactory plug-in to facilitate this. The local publish appears to work just fine - it publishes the two artifacts (both .jar files) and the resolved ivy.xml file as expected. When I request a build on the Hudson server, however, only one of my two artifacts gets published.

The build creates the following artifacts:

ftpSvc.jar
ftpSvc-lib.jar

My ivy.xml file looks like this:

<?xml version="1.0" encoding="ISO-8859-1"?>
<ivy-module version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd">

    <info organisation="esf"
          status="integration"
          module="ftpSvc"
          revision="SNAPSHOT" />

    <publications>
        <artifact name="ftpSvc" ext="jar"/>
        <artifact name="ftpSvc-lib" ext="jar" type="lib" />
    </publications>

    <!--list the dependencies of this project-->
    <dependencies>
        <dependency org="commons-net" name="commons-net" rev="1.3.0" />
    </dependencies>
</ivy-module>

The two artifacts are clearly called out in the <publications> section. The build target in my build.xml file looks like this:

<target name="publish_local" description="publish artifacts locally">
    <echo>organisation: ${ivy.organisation}</echo>
    <echo>module: ${ivy.module}</echo>
    <echo>status: ${ivy.status}</echo>
    <echo>revision: ${ivy.revision}</echo>
    <echo>local dir: ${ivy.default.ivy.user.dir}</echo>

    <ivy:publish
        resolver="local"
        update="true"
        verwrite="true"
        srcivypattern="${bundle.jar.dir}/ivy.xml"
        artifactspattern="${bundle.jar.dir}/[artifact].[ext]" />
</target>

The artifactspattern grabs all defined artifacts from the build directory - nothing fancy going on here. Lastly, the resolver chain in my ivysettings.xml file looks like this (server names changed to protect the innocent):

<resolvers>
    <chain name="main">
        <ibiblio name="main" m2compatible="true" root="http://my.server.employer.com:8080/artifactory/repo" />

        <filesystem name="local"> 
            <ivy pattern="${ivy.default.ivy.user.dir}/local/[organisation]/[module]/[revision]/ivy-[revision].xml" />
            <artifact pattern="${ivy.default.ivy.user.dir}/local/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" /> 
        </filesystem>
    </chain>
</resolvers>

It's all rather routine stuff and, as mentioned above, the local publish works fine. Here's a peek at the console output when I build through Eclipse:

publish_local:
     [echo] organisation: esf
     [echo] module: ftpSvc
     [echo] status: integration
     [echo] revision: SNAPSHOT
     [echo] local dir: C:\Users\myusername\.ivy2
[ivy:publish] :: publishing :: esf#ftpSvc
[ivy:publish]   published ftpSvc to C:\Users\myusername\.ivy2/local/esf/ftpSvc/SNAPSHOT/ftpSvc-SNAPSHOT.jar
[ivy:publish]   published ftpSvc-lib to C:\Users\myusername\.ivy2/local/esf/ftpSvc/SNAPSHOT/ftpSvc-lib-SNAPSHOT.jar
[ivy:publish]   published ivy to C:\Users\myusername\.ivy2/local/esf/ftpSvc/SNAPSHOT/ivy-SNAPSHOT.xml

Both .jar files and the resolved ivy.xml file get published as expected. On my Hudson server, I've got the Artifactory Configuration settings configured thusly (again, some details have been changed to obscure my true superhero identity):

Artifactory server: http://my.server.employer.com:8080/artifactory
Target repository: target-repository
Ivy pattern: [organisation]/[module]/[revision]ivy-[revision].xml
Artifact pattern: "[organisation]/[module]/[revision]/[artifact]-[revision].[ext]"

As you can see, the Ivy and Artifact patterns are exactly the same as the patterns in my local resolver from my ivysettings.xml file. Thus, when the build is run on the Hudson server, I'd expect the exact same artifacts to be published to my Artifactory server.

Let's take a look at the console output from the latest build on my Hudson server:

publish_local:
     [echo] organisation: esf
     [echo] module: ftpSvc
     [echo] status: integration
     [echo] revision: SNAPSHOT
     [echo] local dir: /usr/share/tomcat6/.ivy2
[ivy:publish] :: publishing :: esf#ftpSvc
Collecting Module information for module: ftpSvc
Module location: /usr/share/tomcat6/.hudson/jobs/ftpSvc-ivy/workspace/trunk/out/jars/ftpSvc.jar
[ivy:publish]   published ftpSvc to /usr/share/tomcat6/.ivy2/local/esf/ftpSvc/SNAPSHOT/ftpSvc-SNAPSHOT.jar
Collecting Module information for module: ftpSvc
Module location: /usr/share/tomcat6/.hudson/jobs/ftpSvc-ivy/workspace/trunk/out/jars/ftpSvc-lib.jar
[ivy:publish]   published ftpSvc-lib to /usr/share/tomcat6/.ivy2/local/esf/ftpSvc/SNAPSHOT/ftpSvc-lib-SNAPSHOT.jar
Collecting Module information for module: ftpSvc
Module location: /tmp/ivy2450884590736960955.xml
[ivy:publish]   published ivy to /usr/share/tomcat6/.ivy2/local/esf/ftpSvc/SNAPSHOT/ivy-SNAPSHOT.xml
Build finished triggered
Deploying artifact: http://my.server.employer.com:8080/artifactory/target-repository/esf/ftpSvc/SNAPSHOT/ftpSvc-SNAPSHOT.jar
Deploying artifact: http://my.server.employer.com:8080/artifactory/target-repository/esf/ftpSvc/SNAPSHOT/ftpSvc-SNAPSHOT.xml
Deploying build info to: http://my.server.employer.com.com:8080/artifactory/api/build

Dubya' Tee Eff!? Once again, the local publish appears to work just fine, publishing both jars and the ivy.xml file to the local/esf/ftpSvc/SNAPSHOT/ directory on the Hudson server. The Artifactory plug-in, on the other hand, gets everything totally wrong. Not only does it fail to publish one of the two jars, it renames the ivy.xml file incorrectly.

Are there any Hudson/Ivy/Artifactory experts out there that can shed some light on what's going on here? I've got multiple projects that are exhibiting the exact same behavior. Any and all assistance in resolving this problem would be greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

鲜肉鲜肉永远不皱 2024-10-23 10:01:59

嘿,我没有使用过该插件,但我会尝试从名称 ftpSvc-lib 中删除破折号和/或从其 type="lib" 中删除>artifact 元素,只是为了看看会发生什么。

Hey, I haven't used that plugin, but I would try removing the dash from the name ftpSvc-lib and/or removing type="lib" from its artifact element, just to see what happens.

人间☆小暴躁 2024-10-23 10:01:59

我遇到了同样的问题,在 JFrog Jira 上填充了一个错误,该错误今天已标记为已解决,但正如您在我对 Jira 的评论中看到的那样,我仍然对这个解决方案感到困惑。

https:// /issues.jfrog.org/jira/browse/IAP-26?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel

如果有人有想法,任何输入都会很棒...

I got the same problem, filled a bug on the JFrog Jira, the bug has been marked resolved today, but as you can see in my comments on the Jira, I'm still confused about this resolution.

https://issues.jfrog.org/jira/browse/IAP-26?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel

If anyone has an idea, any input would be great...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文