Configure XL Deploy to fetch artifacts from a Maven repository

This topic describes how to fetch artifacts from a Maven repository. You can access artifacts stored in a Maven repository using the fileUri property of XL Deploy artifacts. To use this feature, you must configure the Maven repositories that XL Deploy will search for artifacts.

Step 1 - Get your Maven repository details

Collect information about the configuration of your environment. The list of repositories that are used by a Maven project are listed in its pom.xml file. Authentication and proxy configuration is specified in the settings.xml file of your development or Jenkins environment. For more information, see Maven Settings Reference.

For example, the pom.xml file may contain:

<repositories>
    <repository>
        <id>xebialabs-releases</id>
        <url>https://nexus.xebialabs.com/nexus/content/repositories/releases/</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
</repositories>

And settings.xml file may contain the following configuration:

<servers>
    <server>
        <id>xebialabs-releases</id>
        <username>deployer</username>
        <password>secret</password>
    </server>
</servers>

Step 2 - Configure XL Deploy Maven repositories

Maven repositories are configured in XL_DEPLOY_SERVER_HOME/conf/xl-deploy.conf. The Maven example configuration above translates to the following HOCON configuration:

xl.artifact.resolver {
  maven {
    repositories: [
      {
        id: xebialabs-releases
        url: "https://nexus.xebialabs.com/nexus/content/repositories/releases/"
        authentication: {
          username: "deployer"
          password: "secret"
        }
        snapshots: {
          enabled: false
        }
      }
    ]
  }
}

The structure of xl-deploy.conf is different from settings.xml and pom.xml. There is a list of repositories (maven.repositories: [...]), and each repository contains the configuration related to it. This configuration includes:

  • Basic information: id and url.
  • authentication configuration with the same elements as servers in settings.xml, such as: username, password, privateKey and passphrase.
  • proxy configuration to use when connecting to this repository. For example:

    xl.artifact.resolver {   
    maven {
      repositories: [
        {
          ...
          proxy: {
            host: "proxy.host.net"
            port: 80
            username: proxyuser
            password: proxypass
          }
        }
      ]
    }
    }
  • Repository policies for releases and snapshots configure whether this repository will be used to search for SNAPSHOT and non-SNAPSHOT versions of artifacts. The value of snapshots should always be false because unstable references, such as snapshots, are not supported.

    The checksumPolicy property configures how strictly XL Deploy will react to unmatched checksums when downloading artifacts from this Maven repository. Permitted values are: ignore, fail, or warn. XL Deploy does not cache remote artifacts locally, this means that the updatePolicy configuration does not apply.

    This is an example configuration of repository policy:

    xl.artifact.resolver {
    maven {
      repositories: [
    	{
    	  ...
    	  releases: {
    		enabled: true
    		checksumPolicy: fail
    	  }
    	  snapshots: {
    		enabled: false
    	  }
    	}
      ]
    }
    }

    The remaining Maven configuration in settings.xml does not apply to XL Deploy. For example, you do not need to specify mirrors because you can use a mirror URL directly in your repository definition, and profiles are used to configure the Maven build, which does not happen in XL Deploy.

Step 3 - Restart XL Deploy

You must restart the XL Deploy server for changes in xl-deploy.conf to be applied.