Skip to content

Commit ffb6c1f

Browse files
author
Rami Bououni
committed
maven yml CL
1 parent 6fe0a8e commit ffb6c1f

File tree

1 file changed

+45
-47
lines changed

1 file changed

+45
-47
lines changed
Lines changed: 45 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
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+
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.
1212

1313
## Prerequisites
1414

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). |
1618

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).
2019

2120
## Publish packages to a feed in the same organization
2221

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

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

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+
```
4948
5049
#### [Classic](#tab/classic/)
5150
@@ -61,29 +60,26 @@ steps:
6160
2. Select **Pipelines**, and then select your pipeline definition.
6261
::: moniker-end
6362
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:
6564

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

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

7571
4. Select **Save & queue** when you're done.
7672

7773
---
7874

7975
> [!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.
8177

8278
## Publish packages to a feed in another organization
8379

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

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

8884
#### Create a service connection
8985

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

9490
1. Select **New service connection**, select **Maven**, and then select **Next**.
9591

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

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

10099
1. Select **Save** when you're done.
101100

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

108107
1. Select **Pipelines**, and then select your pipeline definition.
109108

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>
109+
1. Select **Edit**, and then add the following snippet to your YAML pipeline:
118110

119-
- script: |
120-
mvn deploy
121-
displayName: 'Publish'
122-
```
111+
```yaml
112+
steps:
113+
- task: MavenAuthenticate@0
114+
displayName: 'Authenticate to Azure Artifacts feed'
115+
inputs:
116+
MavenServiceConnections: <NAME_OF_YOUR_SERVICE_CONNECTION>
117+
118+
- script: |
119+
mvn deploy
120+
displayName: 'Publish'
121+
```
123122

124123
#### [Classic](#tab/classic/)
125124

@@ -141,16 +140,13 @@ steps:
141140

142141
::: moniker-end
143142

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

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

148147
1. **Command line task**:
149148
- **Display name**: Publish.
150-
- **Script**:
151-
```
152-
mvn deploy
153-
```
149+
- **Script**: `mvn deploy`
154150

155151
4. Select **Save & queue** when you're done.
156152

@@ -159,5 +155,7 @@ steps:
159155
## Related content
160156

161157
- [Maven Authenticate v0 task](/azure/devops/pipelines/tasks/reference/maven-authenticate-v0)
158+
162159
- [Use the .artifactignore file](../../artifacts/reference/artifactignore.md)
160+
163161
- [Publish and download pipeline artifacts](pipeline-artifacts.md)

0 commit comments

Comments
 (0)