Question

so I have an existing ant build and I'd like to resolve its dependencies using Ivy. I have an ivy.xml and ivysettings.xml file which both work with IvyDE in Eclipse and also work when run from the command line against the ivy-2.3.0.jar. (They work as in Ivy reports it has downloaded the dependencies).

The problem I have is that they do not work when running from the any build script when the 'rev' attribute is listed as 'latest.integration'. If I specify a version then the dependency is resolved. To be clear this specific dependency is an internal library that is hosted by Artifactory.

I'm fairly stumped as to what I can change or try to identify the problem. I get the same failure when running an ivy findrevision.

To note Jenkins is running on a mac, but I can use the Ivy jar directly to resolve the dependencies using the same ivy files on that machine, the problem is only related to when resolving through Jenkins.

I realise this isn't likely to be something someone can look at and point directly to the problem, especially given that in seemingly all other situations, even running the snippet from the ant build through eclipse, the resolve works correctly. But if anyone has any suggestions they'd be more than welcome!

Anyway my ivy.xml

<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="MyOrg"
        module="MyModule"
        status="integration">
    </info>

    <dependencies>
        <dependency org="MyOrg" name="DEP" rev="latest.integration">
            <artifact name="DEP" type="jar" ext="jar" />
        </dependency>
        <dependency org="junit" name="junit" rev="4.8.1" />
    </dependencies>
</ivy-module>

And my ivysettings.xml (The dependency is named for example DEP-0.1-SNAPSHOT.jar)

<?xml version="1.0" encoding="UTF-8"?>
<ivy-settings>
  <settings defaultResolver="snapshot" />
  <!--Authentication required for publishing (deployment). 'Artifactory Realm' is the realm used by Artifactory so don't change it.-->
  <credentials host="HOST" realm="Artifactory Realm" username="USR" passwd="PASS" />
  <resolvers>
    <chain name="main">
      <!-- <ibiblio name="release" m2compatible="true" root="http://HOST/artifactory/libs-release" /> -->
      <chain name="snapshot" changingPattern="0.*" checkmodified="true">
        <ibiblio name="public" m2compatible="true" root="http://HOST/artifactory/libs-snapshot" />
      </chain>
    </chain>
  </resolvers>
</ivy-settings>

And finally my build script looks something like

<project name="MyModule Continuous Integration" xmlns:ivy="antlib:org.apache.ivy.ant">
....
<target name = "resolveDependencies" >
    <ivy:configure file="/MyModule/ivysettings.xml" />
    <ivy:findrevision organisation="MyOrg" module="DEP" revision="latest.integration" property="found.revision" />
    <echo message="Found revision: ${found.revision}" />
    <ivy:resolve file="/MyModule/ivy.xml" refresh="true" type="jar" />
    <ivy:cachepath pathid="ivy.dependencies" />
</target>
....
</project>

And for completion the sort of output I'm getting from the Jenkins build is:

[ivy:findrevision] snapshot: Checking cache for: dependency: MyOrg#DEP;latest.integration {}
[ivy:findrevision] don't use cache for MyOrg#DEP;latest.integration: checkModified=true
[ivy:findrevision] default-cache: no cached resolved revision for MyOrg#DEP;latest.integration
[ivy:findrevision]      tried http://HOST/artifactory/libs-snapshot/MyOrg/DEP/[revision]/DEP-[revision].pom
[ivy:findrevision] CLIENT ERROR: Not Found url=http://HOST/artifactory/libs-snapshot/MyOrg/DEP/maven-metadata.xml
[ivy:findrevision]  maven-metadata not available: http://HOST/artifactory/libs-snapshot/MyOrg/DEP/maven-metadata.xml
[ivy:findrevision] WARN: problem while listing resources in http://HOST/artifactory/libs-snapshot/MyOrg/DEP/ with public:
[ivy:findrevision] WARN:   java.lang.NullPointerException null
[ivy:findrevision]      tried http://HOST/artifactory/libs-snapshot/MyOrg/DEP/[revision]/DEP-[revision].jar
[ivy:findrevision]  maven-metadata not available: http://HOST/artifactory/libs-snapshot/MyOrg/DEP/maven-metadata.xml
[ivy:findrevision] WARN: problem while listing resources in http://HOST/artifactory/libs-snapshot/MyOrg/DEP/ with public:
[ivy:findrevision] WARN:   java.lang.NullPointerException null
[ivy:findrevision]  public: no ivy file nor artifact found for MyOrg#DEP;latest.integration
Property "found.revision" has not been set
     [echo] Found revision: ${found.revision}

Thanks again for any ideas,

Dan.

Was it helpful?

Solution

For future reference, I have managed to resolve this by swapping to the latest Ivy 2.4 alpha build. Seems it must have been a problem with 2.3.0.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top