Fixed the deployment issues!!!

April 04, 2012

I finally figured out how to get Ant + Ivy to copy artifacts from one Artifactory repository to another, modifying the appropriate metadata (AKA "promotion"). First, you need a separate ivy.xml file (I call mine "ivy-publish.xml") that looks like this:

    <ivy-module version="2.0"
        <info organisation="foo" module="FooDeploy" status="integration" />

            <conf name="integration"/>
            <conf name="milestone"/>
            <conf name="release"/>

            <artifact name="Foo" ext="war" />
            <artifact name="Foo-src" ext="jar" />

            <dependency org="foo" name="Foo" rev="latest.integration"
              conf="integration->deploy" transitive="false" />
            <dependency org="foo" name="Foo" rev="latest.milestone"
              conf="milestone->deploy" transitive="false" />
            <dependency org="foo" name="Foo" rev="latest.release"
              conf="release->deploy" transitive="false" />

And then, you need an ant target that looks like this:

    <target name="publish-stage">
        <ivy:configure file="${}/ivysettings.xml"
              host="myserver" realm="Artifactory Realm" username="user"
              passwd="password!" override="true" />
        <ivy:retrieve file="ivy-publish.xml" conf="integration"
        <ivy:buildnumber organisation="${ivy.organisation}"
              module="${ivy.module}" revision="1.0" defaultBuildNumber="1"
              resolver="stage" />
        <ivy:publish resolver="stage"
              status="milestone" overwrite="true" update="true">
            <artifacts pattern="${lib}/integration/[artifact].[ext]" />

What this does is first retrieve the "dependencies" (the artifacts we're interested in) specified in the ivy-publish.xml file to lib/integration. Then, it turns around and publishes them, changing the status from "integration" to "milestone".

Works like a charm.

Jack Lund

Jack Lund

comments powered by Disqus