Maven
Prerequisites
Ensure you have the Maven CLI (
mvn) installed on your local machine.Access to a Harness account with appropriate permissions to create registries and connectors.
Create a Maven Artifact Registry
Navigate to the Artifact Registry module in your Harness project.
Click on New Artifact Registry.
In the Registry Type dropdown, select Maven Registry.
Provide a Registry Name.
Optionally, add a Description and Labels for better organization.
Choose visibility between Public and Private.
Click Create Registry to finalize.
Configure an Upstream Proxy (Optional)
An upstream proxy allows your registry to fetch Maven packages from external sources if they are not available locally.
Create an upstream proxy
1. In the Artifact Registry module, click the dropdown next to **New Artifact Registry** and select **Upstream Proxy**. 2. Choose **Maven Registry** as the proxy type. 3. Click **Create Proxy** to establish the connection.
Configure the upstream proxy in your registry
1. In the Artifact Registry module, select an existing Artifact Registry. 2. Select the **Configuration** tab. 3. Under **Advanced (Optional)**, select **Configure Upstream**. 4. Select from the list of compatible proxies to add them to your registry. 5. Click **Save** to save the configuration.
Push & Pull Maven Packages
Authenticate the CLI with the Harness Registry
In your Harness Maven Artifact Registry, click Setup Client.
Click Generate Identity Token to generate a new token that serves as the password for uploading and downloading artifacts.
Publish a Package to the Registry
Set default repository in your
pom.xmlfile.
Copy the following your ~/ .m2/setting.xml file for MacOs, or $USERPROFILE$\ .m2\settings.xml for Windows to authenticate with token to push to your Maven registry.
Publish the package:
Pull a Package from the Registry
Set default repository in your pom.xml file.
Set the default registry in your pom.xml file by adding the following:
Copy the following your ~/ .m2/settings.xml file for MacOs, or $USERPROFILE$\ .m2\settings.xml for Windows to authenticate with token to pull from your Maven registry.
Add a dependency to the project's pom.xml (replace GROUP_ID, ARTIFACT_ID & VERSION with your own):
Pull the package:
Last updated
Was this helpful?