How to use Nexus groups with Hudson to deploy artifacts post-build?

Posted by John on Stack Overflow See other posts from Stack Overflow or by John
Published on 2010-06-07T06:56:55Z Indexed on 2010/06/07 14:22 UTC
Read the original article Hit count: 1291

Filed under:
|
|
|

Hi there. I'm currently setting up Hudson to push artifacts to my Nexus repository upon succesful builds. Unfortunately I am having some trouble with getting Hudson to deploy using Nexus groups.

I have two groups, upbeat.nexus (private) and public.nexus (public). I've set up the associated repositories in Nexus already. Here's my settings.xml:

<settings>
    <mirrors>
            <mirror>
                    <id>upbeat.nexus</id>
                    <mirrorOf>*</mirrorOf>
                    <url>http://localhost:8099/nexus/content/groups/upbeat</url>
            </mirror>
            <mirror>
                    <id>public.nexus</id>
                    <mirrorOf>*</mirrorOf>
                    <url>http://localhost:8099/nexus/content/groups/public</url>
            </mirror>
    </mirrors>
    <profiles>
            <profile>
                    <id>upbeat.nexus</id>
                      <repositories>
                        <repository>
                            <id>upbeat.central</id>
                            <url>http://central</url>
                            <releases><enabled>true</enabled></releases>
                            <snapshots><enabled>true</enabled></snapshots>
                        </repository>
                      </repositories>
            </profile>
            <profile>
                    <id>public.nexus</id>
                      <repositories>
                        <repository>
                            <id>public.central</id>
                            <url>http://central</url>
                            <releases><enabled>true</enabled></releases>
                            <snapshots><enabled>true</enabled></snapshots>
                        </repository>
                      </repositories>
            </profile>
    </profiles>
    <servers>
            <server>
                    <id>upbeat.nexus</id>
                    <username>build</username>
                    <password></password>
            </server>
            <server>
                    <id>public.nexus</id>
                    <username>build</username>
                    <password></password>
            </server>
    </servers>
    <activeProfiles>
            <activeProfile>upbeat.nexus</activeProfile>
            <activeProfile>public.nexus</activeProfile>
    </activeProfiles>

In Hudson, when setting the "Deploy artifacts to Maven repository", I need to specify the repository URL and the repository ID. I've set the repository ID to "public.nexus" but if I set the URL to http://forge.upbeat.no/nexus/content/repositories/public and the ID to public.nexus I get the following error:

Deploying artifacts to http://forge.upbeat.no/nexus/content/repositories/public
Deploying the main artifact pom.xml
[INFO ] Retrieving previous build number from public.nexus
[INFO ] repository metadata for: 'snapshot com.upbeat.appl:skuldweb:1.0-SNAPSHOT' could not be found on repository: public.nexus, so will be created
ERROR: Error deploying artifact: Failed to transfer file: http://forge.upbeat.no/nexus/content/repositories/public/com/upbeat/appl/skuldweb/1.0-SNAPSHOT/skuldweb-1.0-SNAPSHOT.pom. Return code is: 400
org.apache.maven.artifact.deployer.ArtifactDeploymentException: Error deploying artifact: Failed to transfer file: http://forge.upbeat.no/nexus/content/repositories/public/com/upbeat/appl/skuldweb/1.0-SNAPSHOT/skuldweb-1.0-SNAPSHOT.pom. Return code is: 400
    at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:94)
    at hudson.maven.reporters.MavenArtifactRecord.deploy(MavenArtifactRecord.java:119)
    at hudson.maven.reporters.MavenAggregatedArtifactRecord.deploy(MavenAggregatedArtifactRecord.java:79)
    at hudson.maven.RedeployPublisher.perform(RedeployPublisher.java:109)
    at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:19)
    at hudson.model.AbstractBuild$AbstractRunner.perform(AbstractBuild.java:601)
    at hudson.model.AbstractBuild$AbstractRunner.performAllBuildSteps(AbstractBuild.java:580)
    at hudson.maven.MavenModuleSetBuild$RunnerImpl.post2(MavenModuleSetBuild.java:598)
    at hudson.model.AbstractBuild$AbstractRunner.post(AbstractBuild.java:528)
    at hudson.model.Run.run(Run.java:1264)
    at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:306)
    at hudson.model.ResourceController.execute(ResourceController.java:88)
    at hudson.model.Executor.run(Executor.java:124)
Caused by: org.apache.maven.wagon.TransferFailedException: Failed to transfer file: http://forge.upbeat.no/nexus/content/repositories/public/com/upbeat/appl/skuldweb/1.0-SNAPSHOT/skuldweb-1.0-SNAPSHOT.pom. Return code is: 400
    at org.apache.maven.wagon.providers.http.LightweightHttpWagon.put(LightweightHttpWagon.java:172)
    at org.apache.maven.artifact.manager.DefaultWagonManager.putRemoteFile(DefaultWagonManager.java:244)
    at org.apache.maven.artifact.manager.DefaultWagonManager.putArtifact(DefaultWagonManager.java:160)
    at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:80)
    ... 12 more
Finished: FAILURE

Any tips on how to deploy to a group so I don't have to specify (in Hudson) whether or not I am building a snapshot or a release version, and instead have it look at the version-tag in the pom to automatically place the artifact in the correct repository?

© Stack Overflow or respective owner

Related posts about maven-2

Related posts about hudson