fashuser
fashuser

Reputation: 1479

Override URL to nexus repository specified in pom.xml

I have web project which I am going to deploy to nexus repository after successful build on jenkins. Currently in project in pom.xml I have following configuration as below where host and port to nexus repository is hardcoded:

<profiles>
        <profile>
            <id>deploy-snapshot</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <distributionManagement>
                <snapshotRepository>
                    <id>snapshots</id>
                    <name>Repository for snapshots</name>
                    <url>http://ip1:port1/nexus/content/repositories/snapshots</url>
                </snapshotRepository>
            </distributionManagement>
        </profile>
</profiles>

My goal is override nexus url from jenkins without any changes in pom.xml, because currently that configuration in pom.xml is used on another environment which cannot be reconfigured.

It would be good to know in which way it can be done on jenkins taking into account that in future I am going to make similar for other job which will be in charge of deploying npm packages.

I've looked into following jenkins plugin https://wiki.jenkins.io/display/JENKINS/Nexus+Artifact+Uploader, but not sure that this one is actual one, also not sure that plugin will be good for zip archives for npm build.

Upvotes: 3

Views: 5346

Answers (3)

Nicola Musatti
Nicola Musatti

Reputation: 18218

In the version of Jenkins I'm using, which is ver. 1.602, if you configure your project as a Maven project, you can specify a "Deploy artifacts to Maven repostitory" post build action for which you can indicate the destination repository.

Upvotes: 0

yorammi
yorammi

Reputation: 6458

In order to overwrite it, you can set it in settings.xml file

Upvotes: 0

VonC
VonC

Reputation: 1323753

That was requested in 2008(!) with Make the issue 295: "distributionManagement.site.url configurable from the command line"

In your case, check if passing the property altDeploymentRepository would help:

-DaltDeploymentRepository=...

More precisely, as in "Maven deploy:deploy using -DaltDeploymentRepository"

-DaltDeploymentRepository=releaseRepository::default::http://your.repo.url

"defaut" is the maven2 layout ("legacy" is for maven 1)

Upvotes: 5

Related Questions