Michael G.
Michael G.

Reputation: 163

Deploy snapshots and releases via Maven commandline

I want to deploy projects inside my CI/CD pipeline without using the distributionManagement block inside my pom which would look like this:

<distributionManagement>
    <repository>
        <id>central</id>
        <name>x-releases</name>
        <url>http://serverhostname/artifactory/libs-release-local</url>
    </repository>
    <snapshotRepository>
        <id>snapshots</id>
        <name>x-snapshots</name>
        <url>serverhostname/artifactory/libs-snapshot-local</url>
    </snapshotRepository>
</distributionManagement>

I tried specifying the repositories via command line:

-DaltSnapshotDeploymentRepository=myserver::default::serverhostname/artifactory/libs-snapshot-local \
-DaltReleaseDeploymentRepository=myserver::default::serverhostname/artifactory/artifactory/libs-release-loca

But it fails with

Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter

Specifying -DaltDeploymentRepository allows me to deploy an artifact to a repository, but I am not sure how to distringuish between SNAPSHOT and RELEASE anymore. I thought maven would be able to do this somehow automatically.

What commandline options to use to replace this distributionManagement block?

Upvotes: 1

Views: 1158

Answers (1)

Nyein Chan Wynn
Nyein Chan Wynn

Reputation: 2434

Check your maven-deploy-plugin version.

I was using version 2.7 and getting the same error but upgraded to 2.8.2 and the build completed successfully.

Here's the dependency:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-deploy-plugin</artifactId>
    <version>2.8.2</version>
</plugin>

Upvotes: 1

Related Questions