Configure 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 Deploy artifacts. To use this feature, you must configure the Maven repositories that Deploy will search for artifacts.
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>
settings.xml file may contain the following configuration:
<servers> <server> <id>xebialabs-releases</id> <username>deployer</username> <password>secret</password> </server> </servers>
Maven repositories are configured in
XL_DEPLOY_SERVER_HOME/CentralConfiguration/deploy-artifact-resolver.yaml. The Maven example configuration above translates to the following
deploy.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
deploy-artifact-resolver.yaml is different from
pom.xml. There is a list of repositories (
maven.repositories: [...]), and each repository contains the configuration related to it. This configuration includes:
- Basic information:
authenticationconfiguration with the same elements as
settings.xml, such as:
proxyconfiguration to use when connecting to this repository. For example:
deploy.artifact: maven: repositories: proxy: host: proxy.host.net port: 80 username: proxyuser password: proxypass
Repository policies for
snapshotsconfigure whether this repository will be used to search for
SNAPSHOTversions of artifacts. The value of
snapshotsshould always be
falsebecause unstable references, such as snapshots, are not supported.
checksumPolicyproperty configures how strictly Deploy will react to unmatched checksums when downloading artifacts from this Maven repository. Permitted values are:
warn. Deploy does not cache remote artifacts locally, this means that the
updatePolicyconfiguration does not apply.
This is an example configuration of repository policy:
deploy.artifact: maven: repositories: releases: enabled: true checksumPolicy: fail Snapshots: enabled: false
The remaining Maven configuration in
settings.xml does not apply to 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 Deploy.
You must restart the Deploy server for changes in
deploy-artifact-resolver.yaml to be applied.