Skip to content

Latest commit

 

History

History
141 lines (110 loc) · 5.48 KB

File metadata and controls

141 lines (110 loc) · 5.48 KB
title Connect your Maven project to an Azure Artifacts feed
description Learn how to set up your Maven project and connect to an Azure Artifacts feed.
ms.service azure-devops-artifacts
ms.assetid 944f45ee-baa3-45ba-8467-5e7ab2bc47cf
ms.topic how-to
ms.date 05/05/2025
monikerRange <=azure-devops
recommendations true

Connect to an Azure Artifacts feed - Maven

[!INCLUDE version-lt-eq-azure-devops]

Azure Artifacts enables developers to publish and restore Maven packages from feeds and public registries such as Maven Central and Google Maven Repository. This article walks you through setting up your Maven project and connecting to an Azure Artifacts feed.

Prerequisites

Product Requirements
Azure DevOps - An Azure DevOps organization.
- An Azure DevOps project.
- An Azure Artifacts feed.
- Download and Install Apache Maven.

Project setup

::: moniker range="azure-devops"

  1. Sign in to your Azure DevOps organization, and then navigate to your project.

  2. Select Artifacts, select your feed from the dropdown menu, and then select Connect to feed.

  3. In the left navigation pane, select Maven. Make sure you've installed the prerequisites, if not, select Get the tools in the top-right corner to download and install them.

  4. In the Project setup section, copy the repository snippet and add it to your pom.xml file within the <repositories> and distributionManagement> sections. Your file should resemble the following:

    <repositories>
      <repository>
        <id>FEED_NAME</id>
        <url>https://pkgs.dev.azure.com/<ORGANIZATION_NAME>/<PROJECT_NAME>/_packaging/<FEED_NAME>/maven/v1</url>
        <releases>
          <enabled>true</enabled>
        </releases>
        <snapshots>
          <enabled>true</enabled>
        </snapshots>
      </repository>
    </repositories>
    <distributionManagement>
      <repository>
        <id>FEED_NAME</id>
        <url>https://pkgs.dev.azure.com/<ORGANIZATION_NAME>/<PROJECT_NAME>/_packaging/<FEED_NAME>/maven/v1</url>
        <releases>
          <enabled>true</enabled>
        </releases>
        <snapshots>
          <enabled>true</enabled>
        </snapshots>
      </repository>
    </distributionManagement>
  5. Add the provided snippet to your local settings.xml (located in ${user.home}/.m2):

      <servers>
        <server>
          <id>FEED_NAME</id>
          <username><ORGANIZATION_NAME></username>
          <password>[PERSONAL_ACCESS_TOKEN]</password>
        </server>
      </servers>
  6. Generate a Personal Access Token with Packaging > Read & write scopes, and paste it into the <password> tag in your settings.xml file.

::: moniker-end

::: moniker range="=azure-devops-2022"

  1. Sign in to your Azure DevOps collection, and then navigate to your project.

  2. Select Artifacts, select your feed from the dropdown menu, and then select Connect to feed.

  3. In the left navigation pane, select Maven. Make sure you've installed the prerequisites, if not, select Get the tools in the top-right corner to download and install them.

  4. In the Project setup section, copy the repository snippet and add it to your pom.xml file within the <repositories> and distributionManagement> sections. Your file should resemble the following:

      <repositories>
        <repository>
          <id>FEED_NAME</id>
          <url>http://<SERVER_NAME>/<COLLECTION_NAME>/<PROJECT_NAME>/_packaging/<FEED_NAME>/maven/v1</url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
        </repository>
      </repositories>
      <distributionManagement>
        <repository>
          <id>FEED_NAME</id>
          <url>http://<SERVER_NAME>/<COLLECTION_NAME>/<PROJECT_NAME>/_packaging/<FEED_NAME>/maven/v1</url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
        </repository>
      </distributionManagement>
  5. Add the provided snippet to your local settings.xml (located in ${user.home}/.m2):

      <servers>
        <server>
          <id>FEED_NAME</id>
          <username><COLLECTION_NAME></username>
          <password>[PERSONAL_ACCESS_TOKEN]</password>
        </server>
      </servers>
  6. Generate a Personal Access Token with Packaging > Read & write scopes, and paste it into the <password> tag in your settings.xml file.

::: moniker-end

Tip

If your settings.xml file is shared across your team, you can use Maven to encrypt your passwords.

Related content