Get started with Maven Package Management in Team Services and TFS

Last Update: 5/16/2017

Before you start

This guide assumes you've already set up Package Management. You can check out how to install and license the extension in the Install and license Package Management guide, or go directly to the Extensions Marketplace listing to install.


  1. Apache Maven installed. It can be downloaded from the Apache Maven Site.
  2. Have Package Management installed in your Team Services account.
  3. [Public-opt in only] - To enable Maven support for your account, ask your account admin to go to the "Preview Features" section, choose "for this account", and enable "Maven for Package Management". (Preview Features docs)

Create a feed

Already have a feed? Skip to the next step.

A feed is a container for packages. You consume and publish packages through a particular feed.

To get started, navigate to the Package hub in the Build & Release hub group:

Go to Package hub

If you don't see the Package hub, then ask your account owner to install the Package Management extension from the Visual Studio Marketplace.

Click the dropdown in the top left and select New feed:

New feed button

In the dialog:

  • Give the feed a name and a description (optional).
  • Choose who can read and contribute (or update) packages in your feed. The default selections give Team Build access so that continuous integration builds can add and update packages.
  • When you're done, choose Create.

New feed dialog

You can change these settings later by editing the feed.

Set up authentication

In order to talk to VSTS feeds, you'll need to put a token on your local machine that Maven can pick up and pass to VSTS.

  1. Navigate to the feed that you'd like to use and select Connect to feed.

    Connect to feed button in the upper-right of the page

  2. Open the Maven tab, click Generate Maven credentials, and copy the generated credentials. (images below)

  3. Maven pulls credentials from your settings.xml file:
    • The settings.xml file's path is "${user.home}/.m2/settings.xml" for Linux and "%USERPROFILE%/.m2/settings.xml" for Windows. If the file doesn't exist, create one now.

  4. Beneath the <settings> and <servers> tags in the file, paste the credentials you copied in Step 3 above.

Sample settings.xml:

            <!--The generated token expires on or before 7/19/2017-->
            <value>Basic Y2Fqb…</value>

NOTE: You can find more info on the settings.xml file in the settings.xml reference.

Publish a package

Publish Maven packages to a feed in Package Management to share them with your team and your organization.

In order to publish a Maven package, you'll need to have a Maven package to publish on your local box. If you don't have one, you can generate one by running the following command:

mvn -B archetype:generate -DarchetypeGroupId="org.apache.maven.archetypes" -DgroupId="MyGroup" -DartifactId="myFirstApp"

  1. Set up the Maven client with your feed.
  2. Navigate to the directory containing your Maven package's pom.xml. If you've just created an artifact, the pom.xml will be in the myFirstApp folder.
  3. From the connect to feed dialog in Team Services, copy the <repository> information. Paste it into your pom.xml twice: (See example above)
    • Between the <repositories> tags.
    • Between the <distributionManagement> tags.
  4. From the directory with your pom.xml, run the command mvn deploy. The Maven package should show up in your feed.

Sample pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="" xmlns:xsi="" xsi:schemaLocation="">

See the Maven CLI docs for more publish options.

Install a package from your feed

Install Maven packages from your feed using the Maven client.

The most common way to install a Maven package is as a dependency of another package.

  1. Create a Maven package using the following command:

    mvn -B archetype:generate -DarchetypeGroupId="org.apache.maven.archetypes" -DgroupId="MyGroup" -DartifactId="mySecondApp"
  2. From the connect to feed dialog in Team Services, copy the <repository> information. Paste it into your pom.xml twice: (See example below)

    • Between the <repositories> tags.
    • Between the <distributionManagement> tags.
  3. In Team Services, go to the package you want to install, and copy the <dependency> XML.
  4. Paste the <dependency> information inside the <dependencies> tag of your POM.xml.
  5. Run mvn install from the directory containing your POM.xml.

See the Maven CLI docs for more install options.

Automate the process with continuous integration

You can use continuous integration systems like Team Build to automate the packing and publishing of your packages. To get started with continuous integration, see the Continuous delivery overview

You can also go directly to the Team Build + Maven guide.

What's next?

For more advanced topics, check out the content summary.