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.
11
+
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.
12
12
13
13
## Prerequisites
14
14
15
-
- An Azure DevOps organization. [Create one for free](../../organizations/accounts/create-organization.md).
15
+
|**Product**|**Requirements**|
16
+
|--------------------|--------------------|
17
+
|**Azure DevOps**| - An Azure DevOps [organization](../../organizations/accounts/create-organization.md).<br>- An Azure DevOps [project](../../organizations/projects/create-project.md).<br> - An Azure Artifacts [feed](../../artifacts/start-using-azure-artifacts.md#create-a-new-feed). |
16
18
17
-
- An Azure DevOps project. Create a new [project](../../organizations/projects/create-project.md#create-a-project) if you don't have one already.
18
-
19
-
- An Azure Artifacts feed. [Create one for free](../../artifacts/get-started-maven.md#create-a-feed).
20
19
21
20
## Publish packages to a feed in the same organization
22
21
@@ -34,18 +33,18 @@ Using Azure Pipelines, you can publish your Maven artifacts to Azure Artifacts f
34
33
2. Select **Pipelines**, and then select your pipeline definition.
35
34
::: moniker-end
36
35
37
-
3. Select **Edit**, and then add the following snippet to your YAML pipeline.
36
+
3. Select **Edit**, and then add the following snippet to your YAML pipeline:
38
37
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
-
```
38
+
```yml
39
+
steps:
40
+
- task: MavenAuthenticate@0
41
+
displayName: 'Authenticate to Azure Artifacts feed'
42
+
inputs:
43
+
artifactsFeeds: 'MavenDemo,MavenDemoFeed2'## Select one or multiple feeds to authenticate with.
44
+
- script: |
45
+
mvn deploy
46
+
displayName: 'Publish'
47
+
```
49
48
50
49
#### [Classic](#tab/classic/)
51
50
@@ -61,29 +60,26 @@ steps:
61
60
2. Select **Pipelines**, and then select your pipeline definition.
62
61
::: moniker-end
63
62
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:
63
+
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
64
66
65
1. **Maven Authenticate**: Select one or multiple feeds from the **Feeds** dropdown menu.
67
66
68
67
1. **Command line task**:
69
-
- **Display name**: Publish.
70
-
- **Script**:
71
-
```
72
-
mvn deploy
73
-
```
68
+
- **Display name**: Publish
69
+
- **Script**: `mvn deploy`
74
70
75
71
4. Select **Save & queue** when you're done.
76
72
77
73
---
78
74
79
75
> [!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.
76
+
> 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.
81
77
82
78
## Publish packages to a feed in another organization
83
79
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.
80
+
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.
85
81
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.
82
+
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. Make sure to copy your personal access token as you'll need it in the following section.
87
83
88
84
#### Create a service connection
89
85
@@ -93,9 +89,12 @@ Navigate to the organization hosting your target feed and [Create a personal acc
93
89
94
90
1. Select **New service connection**, select **Maven**, and then select **Next**.
95
91
96
-
1. Select **Username and Password** as the **Authentication method**, and then enter your **Repository URL** and your **Repository Id**.
92
+
1. For **Authentication method**, select **Username and Password**. Enter your **Repository URL** and your **Repository Id**.
97
93
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.
94
+
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).
95
+
- For **Password**, paste the personal access token you created earlier.
96
+
- Provide a **Name** for your service connection.
97
+
- Check the **Grant access permission to all pipelines** checkbox.
99
98
100
99
1. Select **Save** when you're done.
101
100
@@ -107,19 +106,19 @@ Navigate to the organization hosting your target feed and [Create a personal acc
107
106
108
107
1. Select **Pipelines**, and then select your pipeline definition.
109
108
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:
143
+
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
144
146
-
1. **Maven Authenticate**: Select your service connection from the **Credentials for repositories outside this organization/collection** dropdown menu.
145
+
1. **Maven Authenticate**: From the **Credentials for repositories outside this organization/collection** dropdown, select your service connection.
0 commit comments