Set up Azure Pipelines and Maven

Azure Pipelines | Azure DevOps Server 2019 | TFS 2018


In Microsoft Team Foundation Server (TFS) 2018 and previous versions, run and release pipelines are called definitions, runs are called builds, service connections are called service endpoints, stages are called environments, and jobs are called phases.

This guide covers the basics of using Azure Pipelines to work with Maven artifacts in Azure Artifacts feeds.

  1. Navigate to your Maven feed and click "Connect to Feed". Click on "Maven". Connect to Feed - Maven

  2. Click on "Generate Maven Credentials"

  3. Create a local file named settings.xml from the following template and then paste the generated XML, replacing the comment:


    Do not commit this file into your repository.

    <settings xmlns="" xmlns:xsi="" xsi:schemaLocation="
          <!-- Paste the <server> snippet generated by Azure DevOps here -->
  4. Below the settings.xml snippet in the generated credentials dialog, there is a snippet to be added to the <repositories> section of your project's pom.xml. Add that snippet. If you intend to use Maven to publish to Artifacts, add the snippet to the <distributionManagement> section of the POM file as well. Commit and push this change.

  5. Upload settings.xml created in step 3 as a Secure File into the pipeline's library.

  6. Add tasks to your pipeline to download the secure file and to copy it to the (~/.m2) directory. The latter can be accomplished with the following PowerShell script, where settingsxml is the reference name of the "Download secure file" task:

New-Item -Type Directory -Force "${HOME}/.m2"
Copy-Item -Force "$(settingsxml.secureFilePath)" "${HOME}/.m2/settings.xml"