0

I build weekly a large third-party project (apache sling) in Jenkins. I've got jenkin's settings.xml set up to use my own archiva server to download all dependencies (using the mirror section).

However, I haven't figured out how to get the build to upload snapshots my own snapshots repository when doing a 'deploy'. It instead tries to upload the snapshots to an apache.org snapshots server and fails.

Is there a way to configure settings.xml to override the snapshots server in a similar way it's possible to override the repository? This has to be done without editing the project's pom.xml.

The reason I need to do this is because I need access to some of the snapshot versions as dependencies in another project, and I don't want to have to manually upload them all into archiva.

Here's my settings.xml:

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">

<localRepository>/Users/Shared/Jenkins/.m2/repository</localRepository>

<servers>
    <server>
        <id>astra.internal</id>
        <username>-deleted-</username>
        <password>-deleted-</password>
    </server>
    <server>
        <id>astra.snapshots</id>
        <username>-deleted-</username>
        <password>-deleted-</password>
    </server>
</servers>

<mirrors>
    <mirror>
        <id>central-proxy</id>
        <name>Local proxy of central repo</name>
        <url>http://-deleted-.com/repository/internal</url>
        <mirrorOf>central</mirrorOf>
    </mirror>
    <mirror>
        <id>snapshots</id>
        <name>Local proxy of snapshots</name>
        <url>http://-deleted-.com/repository/internal</url>
        <mirrorOf>snapshots</mirrorOf>
    </mirror>
</mirrors>

<profiles>
    <profile>
        <id>Repository Proxy</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <!-- ******************************************************* -->
        <!-- repositories for jar artifacts -->
        <profile>
            <!-- ******************************************************* -->
            <repositories>
                <repository>
                    <id>astra.internal</id>
                    <url>http://-deleted-.com/repository/internal/</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                </repository>

                <repository>
                    <id>astra.snapshots</id>
                    <url>http://-deleted-.com/repository/snapshots/</url>
                    <releases>
                        <enabled>false</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </repository>
            </repositories>
        </profile>
    </profiles>
</settings>

3 Answers3

0

The location of the repository is part of the pom.xml, the distributionManagement often in one of the upper-most parents. So it is not something you can set from the settings.xml. There's a good chance that you can change it with the distMgmtSnapshotsUrl property, see org.apache:apache:13:pom, assuming the sling-project uses this as its (indirect) parent.

Robert Scholte
  • 11,889
  • 2
  • 35
  • 44
0

As far as I know you have to edit the pom file for the project and have this section (with your server settings of course):

  <distributionManagement>
    <repository>
      <id>archiva.internal</id>
      <name>Internal Release Repository</name>
      <url>dav:http://localhost:8080/repository/internal</url>
    </repository>
    <snapshotRepository>
      <id>archiva.snapshots</id>
      <name>Internal Snapshot Repository</name>
      <url>http://localhost:8080/repository/snapshots</url>
    </snapshotRepository>
  </distributionManagement>

Would it help you to put it in a company wide pom you inherit from?

Jon
  • 188
  • 1
  • 8
0

You can overwrite the Distribution management section with command line parameters.

mvn clean deploy -DaltDeploymentRepository=ui-snapshots::default::http://localhost:8081/artifactory/libs-snapshot-local/

Have a look at the maven deploy plugin.

Alternatively, you should be able to use the Jenkins post build step. There you need to specifically provide the Repo url anyway.

Peter Schuetze
  • 16,185
  • 4
  • 44
  • 58
  • I'll try the distribution management command line arg, but yeah, good idea about doing a jenkins post build step if the arg doesn't work. This way I could be a bit more picky on what exactly I upload to archiva. – Robert A. Decker Oct 29 '13 at 12:56