Skip to content

Commit 377d5fa

Browse files
authored
Merge pull request #8066 from MicrosoftDocs/pipelines/437476
Publish Maven packages yml/CL
2 parents 2619be3 + 04fb0c9 commit 377d5fa

File tree

1 file changed

+54
-49
lines changed

1 file changed

+54
-49
lines changed
Lines changed: 54 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
---
2-
title: Publish Maven artifacts
2+
title: Publish Maven artifacts with Azure Pipelines
33
description: Learn how to publish Maven artifacts to internal and external feed using Azure Pipelines.
44
ms.topic: how-to
5-
ms.date: 11/18/2024
5+
ms.date: 06/30/2025
66
monikerRange: '>= azure-devops-2020'
77
---
88

99
# Publish Maven artifacts with Azure Pipelines (YAML/Classic)
1010

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+
[!INCLUDE [version-gt-eq-2020](../../includes/version-gt-eq-2020.md)]
1212

13-
## Prerequisites
14-
15-
- 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.
1614

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
1816

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> &nbsp;&nbsp;&nbsp;&nbsp;- 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> &nbsp;&nbsp;&nbsp;&nbsp;- To create service connections, you must have the *Administrator* or *Creator* role for [service connections](../library/add-resource-protection.md). |
2020

2121
## Publish packages to a feed in the same organization
2222

@@ -34,18 +34,18 @@ Using Azure Pipelines, you can publish your Maven artifacts to Azure Artifacts f
3434
2. Select **Pipelines**, and then select your pipeline definition.
3535
::: moniker-end
3636

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:
3838

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+
```
4949
5050
#### [Classic](#tab/classic/)
5151
@@ -61,29 +61,32 @@ steps:
6161
2. Select **Pipelines**, and then select your pipeline definition.
6262
::: moniker-end
6363
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:
6565

6666
1. **Maven Authenticate**: Select one or multiple feeds from the **Feeds** dropdown menu.
6767

6868
1. **Command line task**:
69-
- **Display name**: Publish.
70-
- **Script**:
71-
```
72-
mvn deploy
73-
```
69+
- **Display name**: Publish
70+
- **Script**: `mvn deploy`
7471

7572
4. Select **Save & queue** when you're done.
7673

7774
---
7875

7976
> [!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
8180

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.
8382

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
8584

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.
8790

8891
#### Create a service connection
8992

@@ -93,9 +96,12 @@ Navigate to the organization hosting your target feed and [Create a personal acc
9396

9497
1. Select **New service connection**, select **Maven**, and then select **Next**.
9598

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**.
97100

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.
99105

100106
1. Select **Save** when you're done.
101107

@@ -107,19 +113,19 @@ Navigate to the organization hosting your target feed and [Create a personal acc
107113

108114
1. Select **Pipelines**, and then select your pipeline definition.
109115

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'
116-
inputs:
117-
MavenServiceConnections: <NAME_OF_YOUR_SERVICE_CONNECTION>
116+
1. Select **Edit**, and then add the following snippet to your YAML pipeline:
118117

119-
- script: |
120-
mvn deploy
121-
displayName: 'Publish'
122-
```
118+
```yaml
119+
steps:
120+
- task: MavenAuthenticate@0
121+
displayName: 'Authenticate to Azure Artifacts feed'
122+
inputs:
123+
MavenServiceConnections: <NAME_OF_YOUR_SERVICE_CONNECTION>
124+
125+
- script: |
126+
mvn deploy
127+
displayName: 'Publish'
128+
```
123129

124130
#### [Classic](#tab/classic/)
125131

@@ -141,16 +147,13 @@ steps:
141147

142148
::: moniker-end
143149

144-
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:
145151

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.
147153

148154
1. **Command line task**:
149155
- **Display name**: Publish.
150-
- **Script**:
151-
```
152-
mvn deploy
153-
```
156+
- **Script**: `mvn deploy`
154157

155158
4. Select **Save & queue** when you're done.
156159

@@ -159,5 +162,7 @@ steps:
159162
## Related content
160163

161164
- [Maven Authenticate v0 task](/azure/devops/pipelines/tasks/reference/maven-authenticate-v0)
165+
162166
- [Use the .artifactignore file](../../artifacts/reference/artifactignore.md)
167+
163168
- [Publish and download pipeline artifacts](pipeline-artifacts.md)

0 commit comments

Comments
 (0)