title | description | ms.topic | ms.date | monikerRange |
---|---|---|---|---|
Restore Maven packages (YAML/Classic) |
Learn how to restore Maven packages from internal and external feed using Azure Pipelines. |
how-to |
02/04/2025 |
<= azure-devops |
This article guides you through setting up your YAML and Classic pipelines to restore your Maven packages from internal and external feeds.
Product | Requirements |
---|---|
Azure DevOps | - An Azure DevOps project. - An Azure Artifacts feed. - Permissions: - To grant access to all pipelines in the project, you must be a member of the Project Administrators group. - To create service connections, you must have the Administrator or Creator role for service connections. |
::: moniker range="azure-devops"
- Sign in to your Azure DevOps organization, and then navigate to your project. ::: moniker-end
::: moniker range="< azure-devops"
- Sign in to your Azure DevOps collection, and then navigate to your project. ::: moniker-end
::: moniker range="<=azure-devops" 2. Select Pipelines, and then select your pipeline definition. ::: moniker-end
- Select Edit, and then add the following snippet to your YAML pipeline.
steps:
- task: MavenAuthenticate@0
displayName: 'Maven Authenticate'
inputs:
artifactsFeeds: 'YOUR_FEED_NAME'
- script: |
mvn install
::: moniker range="azure-devops"
- Sign in to your Azure DevOps organization, and then navigate to your project. ::: moniker-end
::: moniker range="< azure-devops"
- Sign in to your Azure DevOps collection, and then navigate to your project. ::: moniker-end
::: moniker range="<=azure-devops" 2. Select Pipelines, and then select your pipeline definition. ::: moniker-end
-
Select Edit, and then select the
+
sign to add a new task. Add the Maven Authenticate and Command line tasks to your pipeline definition and configure them as follows:-
Maven Authenticate: Select one or multiple feeds from the Feeds dropdown menu.
-
Command line task:
- Display name: Restore.
- Script:
mvn install
-
-
Select Save & queue when you're done.
To restore your packages from a feed in another Azure DevOps organization, you must first create a personal access token in the target organization, and then create a service connection to authenticate with the target feed.
-
Navigate to the target organization where the feed is hosted
-
Create a personal access token with Packaging > Read & write scope.
-
Copy your personal access token as you'll need it in the next step.
-
Sign in to the Azure DevOps organization where your pipeline will run, and then navigate to your project.
-
Navigate to Project settings > Service connections.
-
Select New service connection, select Maven, and then select Next.
-
Select Username and Password as the Authentication method, and then enter your Repository URL and your Repository Id.
-
Enter your Username (a placeholder, as Azure Pipelines will use your
pom.xml
and the personal access token you created earlier to authenticate). For Password, paste your personal access token. -
Provide a Name for your service connection, and select Grant access permission to all pipelines.
-
Select Save when you're done.
-
Sign in to your Azure DevOps organization, and then navigate to your project.
-
Select Pipelines, and then select your pipeline definition.
-
Select Edit, and then add the following snippet to your YAML pipeline.
steps:
- task: MavenAuthenticate@0
displayName: 'Maven Authenticate'
inputs:
MavenServiceConnections: <SERVICE_CONNECTION_NAME>
- script: |
mvn install
displayName: 'Restore'
::: moniker range="azure-devops"
- Sign in to your Azure DevOps organization, and then navigate to your project.
::: moniker-end
::: moniker range="< azure-devops"
- Sign in to your Azure DevOps collection, and then navigate to your project.
::: moniker-end
::: moniker range="<=azure-devops"
- Select Pipelines, and then select your pipeline definition.
::: moniker-end
-
Select Edit, and then select the
+
sign to add a new task. Add the Maven Authenticate and Command line tasks to your pipeline definition and configure them as follows:-
Maven Authenticate: Select your service connection from the Credentials for repositories outside this organization/collection dropdown menu.
-
Command line task:
- Display name: Restore.
- Script:
mvn install
-
-
Select Save & queue when you're done.