You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
title: Publish Maven artifacts with Azure Pipelines
3
3
description: Learn how to publish Maven artifacts to internal and external feed using Azure Pipelines.
4
4
ms.topic: how-to
5
-
ms.date: 11/18/2024
5
+
ms.date: 06/30/2025
6
6
monikerRange: '>= azure-devops-2020'
7
7
---
8
8
9
9
# Publish Maven artifacts with Azure Pipelines (YAML/Classic)
10
10
11
-
Using Azure Pipelines, you can publish your Maven artifacts to Azure Artifacts feeds in your organization, in other organizations, and to public registries such as Maven Central. This article will guide you through publishing your Maven artifacts using both YAML and Classic pipelines.
- An Azure DevOps organization. [Create one for free](../../organizations/accounts/create-organization.md).
13
+
Azure Pipelines enables developers to publish Maven artifacts to Azure Artifacts feeds within the same organization, across other organizations, and to public registries such as Maven Central. This article guides you through publishing your Maven artifacts using both YAML and Classic pipelines.
16
14
17
-
- An Azure DevOps project. Create a new [project](../../organizations/projects/create-project.md#create-a-project) if you don't have one already.
15
+
## Prerequisites
18
16
19
-
- An Azure Artifacts feed. [Create one for free](../../artifacts/get-started-maven.md#create-a-feed).
17
+
|**Product**|**Requirements**|
18
+
|--------------------|--------------------|
19
+
|**Azure DevOps**| - An Azure DevOps [organization](../../organizations/accounts/create-organization.md) and a [project](../../organizations/projects/create-project.md).<br> - An Azure Artifacts [feed](../../artifacts/start-using-azure-artifacts.md#create-a-new-feed).<br> - A [working pipeline](../create-first-pipeline.md).<br> - **Permissions:**<br> - To grant access to all pipelines in the project, you must be a member of the [Project Administrators group](../../organizations/security/change-project-level-permissions.md).<br> - To create service connections, you must have the *Administrator* or *Creator* role for [service connections](../library/add-resource-protection.md). |
20
20
21
21
## Publish packages to a feed in the same organization
22
22
@@ -34,18 +34,18 @@ Using Azure Pipelines, you can publish your Maven artifacts to Azure Artifacts f
34
34
2. Select **Pipelines**, and then select your pipeline definition.
35
35
::: moniker-end
36
36
37
-
3. Select **Edit**, and then add the following snippet to your YAML pipeline.
37
+
3. Select **Edit**, and then add the following snippet to your YAML pipeline:
38
38
39
-
```yml
40
-
steps:
41
-
- task: MavenAuthenticate@0
42
-
displayName: 'Authenticate to Azure Artifacts feed'
43
-
inputs:
44
-
artifactsFeeds: 'MavenDemo,MavenDemoFeed2'## Select one or multiple feeds to authenticate with.
45
-
- script: |
46
-
mvn deploy
47
-
displayName: 'Publish'
48
-
```
39
+
```yml
40
+
steps:
41
+
- task: MavenAuthenticate@0
42
+
displayName: 'Authenticate to Azure Artifacts feed'
43
+
inputs:
44
+
artifactsFeeds: 'MavenDemo,MavenDemoFeed2'## Select one or multiple feeds to authenticate with.
45
+
- script: |
46
+
mvn deploy
47
+
displayName: 'Publish'
48
+
```
49
49
50
50
#### [Classic](#tab/classic/)
51
51
@@ -61,29 +61,32 @@ steps:
61
61
2. Select **Pipelines**, and then select your pipeline definition.
62
62
::: moniker-end
63
63
64
-
3. 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:
64
+
3. 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:
65
65
66
66
1. **Maven Authenticate**: Select one or multiple feeds from the **Feeds** dropdown menu.
67
67
68
68
1. **Command line task**:
69
-
- **Display name**: Publish.
70
-
- **Script**:
71
-
```
72
-
mvn deploy
73
-
```
69
+
- **Display name**: Publish
70
+
- **Script**: `mvn deploy`
74
71
75
72
4. Select **Save & queue** when you're done.
76
73
77
74
---
78
75
79
76
> [!NOTE]
80
-
> To publish packages to a feed using Azure Pipelines, make sure that both the *Project Collection Build Service* and your project's *Build Service* identities have the **Feed Publisher (Contributor)** role in your feed settings. See [Manage permissions](../../artifacts/feeds/feed-permissions.md#pipelines-permissions) for more details.
77
+
> To publish packages to a feed using Azure Pipelines, make sure that both the **Project Collection Build Service** and your project's **Build Service** identities are assigned the **Feed Publisher (Contributor)** role in your feed settings. See [Manage permissions](../../artifacts/feeds/feed-permissions.md#pipelines-permissions) for more details.
78
+
79
+
## Publish packages to a feed in a different organization
81
80
82
-
## Publish packages to a feed in another organization
81
+
To publish packages to a feed in a different Azure DevOps organization, you must first create a personal access token (PAT) in the target organization, and then use that PAT to create a service connection and authenticate with the target feed.
83
82
84
-
To publish your packages to a feed in another Azure DevOps organization, you must first create a personal access token in the target organization.
83
+
#### Create a personal access token
85
84
86
-
Navigate to the organization hosting your target feed and [Create a personal access token](../../organizations/accounts/use-personal-access-tokens-to-authenticate.md) with **Packaging** > **Read & write** scope. Copy your personal access token as you'll need it in the following section.
85
+
1. Navigate to the organization that hosts the target feed.
86
+
87
+
1. [Create a personal access token](../../organizations/accounts/use-personal-access-tokens-to-authenticate.md) with **Packaging** > **Read & write** scope.
88
+
89
+
1. Copy your personal access token as you'll need it in the following section.
87
90
88
91
#### Create a service connection
89
92
@@ -93,9 +96,12 @@ Navigate to the organization hosting your target feed and [Create a personal acc
93
96
94
97
1. Select **New service connection**, select **Maven**, and then select **Next**.
95
98
96
-
1. Select **Username and Password** as the **Authentication method**, and then enter your **Repository URL** and your **Repository Id**.
99
+
1. For **Authentication method**, select **Username and Password**. Enter your **Repository URL** and your **Repository Id**.
97
100
98
-
1. Enter your **Username** (a placeholder, as Azure Pipelines will use your `pom.xml` configuration file 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 check the **Grant access permission to all pipelines** checkbox.
101
+
1. In the **Username** field, enter any string value (this is required, but Azure Pipelines will use your `pom.xml` configuration and the personal access token you created earlier for authentication).
102
+
- For **Password**, paste the personal access token you created earlier.
103
+
- Provide a **Name** for your service connection.
104
+
- Check the **Grant access permission to all pipelines** checkbox.
99
105
100
106
1. Select **Save** when you're done.
101
107
@@ -107,19 +113,19 @@ Navigate to the organization hosting your target feed and [Create a personal acc
107
113
108
114
1. Select **Pipelines**, and then select your pipeline definition.
109
115
110
-
1. Select **Edit**, and then add the following snippet to your YAML pipeline.
111
-
112
-
```yaml
113
-
steps:
114
-
- task: MavenAuthenticate@0
115
-
displayName: 'Authenticate to Azure Artifacts feed'
3. 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:
150
+
3. Select **Edit**, and then select the `+` icon to add a new task. Add the **Maven Authenticate** and **Command line** tasks to your pipeline definition and configure them as follows:
145
151
146
-
1. **Maven Authenticate**: Select your service connection from the **Credentials for repositories outside this organization/collection** dropdown menu.
152
+
1. **Maven Authenticate**: From the **Credentials for repositories outside this organization/collection** dropdown, select your service connection.
0 commit comments