Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Azure DevOps Services | Azure DevOps Server | Azure DevOps Server 2022 | Azure DevOps Server 2020
Using Azure Artifacts upstream sources allows you to use a single feed to host both your own packages and packages from public registries such as Maven Central. When upstream sources are enabled, Azure Artifacts automatically saves a copy of any package installed from an upstream source. This ensures your development process can continue seamlessly even if a public registry experiences an outage.
Note
Maven snapshots are not supported in Maven upstream sources.
Prerequisites
| Product | Requirements |
|---|---|
| Azure DevOps | - An Azure DevOps organization. - An Azure DevOps project. - Download and Install Apache Maven. |
Create a feed
If you already have an Azure Artifacts feed, skip to the next section. Otherwise, follow these steps to create one:
Sign in to Azure DevOps and navigate to your project.
Select Artifacts, then select Create Feed.
Provide a Name for your feed, set the Visibility to control who can access your packages, and choose the feed Scope. Make sure to check Include packages from common public sources to enable upstream sources and allow consumption of packages from public registries.
Select Create to finish creating the feed.
Add Maven Central upstream
If you selected the upstream sources checkbox when setting up your feed, Maven Central should already be added as an upstream source. Otherwise, you can manually add it by following these steps:
Sign in to your Azure DevOps, and navigate to your project.
Select Artifacts, then select the
button in the top right corner to navigate to your Feed Settings.Select Upstream sources, then select Add Upstream.
Select Public source, select Maven Central (https://repo.maven.apache.org/maven2/) from the dropdown menu, and then select Add when you're done.
Select Save in the top right corner to save your changes.
Connect to your feed
Before you can start saving packages from upstream sources, you must first set up your project and connect to your feed.
Sign in to Azure DevOps, then navigate to your project.
Select Artifacts, then select your feed from the dropdown menu.
Select Connect to Feed, then select Maven from the left panel.
Make sure you've installed the prerequisites, then follow the steps in the Project setup section to set up your pom.xml and settings.xml files and connect to your feed. See Project setup - Maven for more details.
Use packages from Maven Central
The following example illustrates how to consume the Apache HttpClient package from Maven Central using the command line.
Note
To save packages from upstreams, you must have the Feed and Upstream Reader (Collaborator) role or higher. See Feed roles and permissions for more details.
Navigate to Maven Central
https://mvnrepository.com/.Search for Apache HttpClient. Select the package, then select the version you wish to install.
Under the Maven tab, copy the
<dependency>snippet:<dependency> <groupId>org.apache.httpcomponents.client5</groupId> <artifactId>httpclient5</artifactId> <version>5.5.1</version> </dependency>Open your pom.xml file and paste the snippet inside the
<dependencies>tag, then save your file.Run the following command from the same directory as your pom.xml file to install your dependencies:
mvn install
View saved packages
Now that you've installed a package from Maven Central, you can see how Azure Artifacts automatically saved a copy of that package to your feed. You can filter your feed view to see packages saved from different upstream sources.
Sign in to Azure DevOps, and navigate to your project.
Select Artifacts, then select your feed from the dropdown menu.
From the source dropdown, select Maven Central to filter for packages from this upstream.
The Apache HttpClient* package that you saved in the previous step is now available in your feed.
Tip
If Maven is not downloading all your dependencies, run the following command from the project directory to regenerate your project files:
mvn eclipse:eclipse -DdownloadSources=true -DdownloadJavadocs=true