Publish Maven artifacts from the command line

Azure DevOps Services | TFS 2018

Publish Maven artifacts to a feed in Azure Artifacts to share them with your team and organization.

To publish a Maven artifact, you'll need to have a Maven artifact to publish on your local machine. 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 artifact's pom.xml file. If you've just created an artifact, the pom.xml file will be in the myFirstApp folder.

  3. From the directory containing your pom.xml file, run the following commands to build and deploy your Maven artifact:

    • Build your package:

      mvn build
      
    • Publish your package:

      mvn deploy
      

Your Maven artifact should appear in your feed now. See the Apache Maven Deploy Plugin to learn more about Maven deployment.

Tip

If you want to publish a 3rd party assembly to a Maven feed, you can use the deploy:deploy-file Mojo. This mojo is used primarily to publish artifacts that were not built by Maven and you can use it with or without a POM file.

mvn deploy:deploy-file -Dpackaging="jar" -DrepositoryId="MyFeedName" -Durl="MyFeedURL" -DgroupId="MyGroup" -DartifactId="myFirstApp" -Dversion="jarFileVersion" -Dfile="jarFileLocalPath"