Reputation: 1422
I attempt to build a CI/CD pipeline that:
mvn deploy
to deploy the client lib to the remote repository.However, the autogenerated pom.xml
does not have the configuration of <repositories>
and <distributionManagement>
.
I am looking for a Maven-native solution to programmatically add <repositories>
and <distributionManagement>
configuration to this auto-generated pom.xml
.
Autogenerated pom.xml
that only lives in the lifecycle of a CI/CD build
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
...
<url>https://github.com/swagger-api/swagger-codegen</url>
<description>Swagger Java</description>
<scm>
<connection>scm:git:[email protected]:swagger-api/swagger-codegen.git</connection>
<developerConnection>scm:git:[email protected]:swagger-api/swagger-codegen.git</developerConnection>
<url>https://github.com/swagger-api/swagger-codegen</url>
</scm>
<licenses>
<license>
<name>Unlicense</name>
<url>http://unlicense.org</url>
<distribution>repo</distribution>
</license>
</licenses>
<developers>
<developer>
<name>Swagger</name>
<email>[email protected]</email>
<organization>Swagger</organization>
<organizationUrl>http://swagger.io</organizationUrl>
</developer>
</developers>
<build>
...
</build>
<profiles>
...
</profiles>
<dependencies>
...
</dependencies>
<properties>
...
</properties>
</project>
The snippet I want to add into pom.xml
:
<repositories>
<repository>
<id>...</id>
<url>...</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>...</id>
<url>...</url>
</repository>
</distributionManagement>
Upvotes: 6
Views: 2602
Reputation: 464
I was able to achieve this by passing a command-line argument to mvn deploy:
mvn deploy -DaltDeploymentRepository=ID::URL
ID
is the id of the server in your settings.xml
URL
is the URL of the deployment endpoint as you would use in distributionManagement/url
part of your pom.xml
.Upvotes: 6