3

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.

fashuser
  • 2,152
  • 3
  • 29
  • 51

3 Answers3

5

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)

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

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

yorammi
  • 6,272
  • 1
  • 28
  • 34
  • Thank you for answer. Could you please suggest which settings can be used in settings.xml in order to do this? I've tried few samples, but unfortunately those samples didn't work. – fashuser Sep 17 '17 at 20:02
  • Use mirror settings – yorammi Sep 18 '17 at 05:18
0

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.

Nicola Musatti
  • 17,834
  • 2
  • 46
  • 55