Creating Maven repositories
Build can act as a Maven repository for projects that are built in Build, and can serve as a caching proxy for external Maven repositories.
Before you begin
Before you start the integration, ensure that these preconditions are met:
- The build agent must be in the same location as Maven (or Maven must be downloaded with the project).
- You must have administrative permissions to configure projects and have access to the Build System page.
- You must be able to edit the Maven settings.xml file, which is usually located in the /user.home/.m2/ directory. By default, this file does not exist and Maven uses default values for configuration properties. If you create the file and place it in the location specified, Maven usees it instead of the default values. Maven provides an sample settings.xml for you to use and modify, which is found in the maven_install_dir/conf directory.
- You must be able to edit the Maven POM file, which is usually located in the Maven application's root directory.
Modify the Maven POM file to reference the repository that is used by Build. The POM file should look similar to this example:
<project>
<distributionManagement>
<repository>
<id>DevOps_Build</id>
<name>DevOps Build Repo</name>
<url>${env.DEVOPS_BUILD_WEB_URL}rest/maven2dist/${env.DEVOPS_BUILD_BUILD_LIFE_ID}</url>
</repository>
<snapshotRepository>
<uniqueVersion>false</uniqueVersion>
<id>DevOps_Build</id>
<name>DevOps_Build Repo</name>
<url>${env.DEVOPS_BUILD_WEB_URL}rest/maven2dist/${env.DEVOPS_BUILD_BUILD_LIFE_ID}</url>
</snapshotRepository>
</distributionManagement>
</project>
Modify the settings.xml file in the location where the agent that is accessing Maven is located. The file must provide a user name and password for Maven authentication, similar to the example in the following code fragment:
<settings>
<servers>
<server>
<id>DevOps_Build</id>
<username>username</username>
<password>password</password>
</server>
</servers>
</settings>
About this task
With this integration, you can retrieve artifacts from CodeStation or directly from your Maven repositories. The integration provides visibility into the project dependencies you manage using Maven 2.
Procedure
- On the left navigational panel, click System, then click Maven under Integrations.
- In the New Maven Repository dialog, type a name for the repository in the Name field.
- Enter a description the repository in the Description area.
-
Type the URL for the Maven repository in the URL field.
The format is [HOST]:[PORT]; for example, http://maven.domain.com:8080.
- Type the Maven user name fin the User Name field.
- Type the password for the account in the Password field.
- Optional: To configure a proxy server, see Creating proxy servers.
- To verify transferred Maven files, select Verify Hashes.
- Click Save.
