19 June 2009

Hudson, Maven and Nexus Credentials

I decided to figure out how to post my Logger project from Hudson to Nexus.

Outline this time (I'm in a hurry)

* Go to Nexus which, in my case, is http://nexus.flatland.com:8090/nexus.
* Login as Admin
* Click "user" in the left sidebar
* Click add a user in the top of the main window
* I added one called 'hudson'.
* I gave it two permissions. 'Nexus Deployment Role' and 'Repo: All repositories (full control'
* It has to be active but the other fields are self-evident.
* Save the changes.

Now you have to make sure the repo can be deployed to:

* Still logged into Nexus as Admin.
* Click "Repositories" in the left sidebar.
* Choose 'releases' at the top (or 'snapshots' if you want to deploy a snapshot)
* Choose the 'configuration' tab
* Maybe you scroll down, maybe not, but get to the "Allow deployments" entry and make sure it is 'true'.
* If you changed it, you have to 'save' the result.

On the build server you will need to edit settings.xml to add credentials for Hudson to use with Nexus. On my Red Hat Linux server it is in ~/.m2/settings.xml (/home/hudson/.m2/settings.xml on my server).

This should go into the settings.xml file. It goes in the <servers> section.

<server>
<id>nexus.flatland.com</id>
<username>hudson</username>
<password>password</password>
</server>

Now Nexus will let the 'hudson' user deploy something.

* Go to Hudson.
* Select the Logging job.
* Click on one of the builds in the list of builds at the bottom of the left sidebar. (Usually you will want to pick the most recent build but older ones will let you restore something older.)
* Click "Redeploy Artifacts" among the left sidebar options. It has a green curvy arrow icon.
* Enter (or use the down arrow to get the list) the Nexus repo URL. It will look something like this: http://nexus.flatland.com:8090/nexus/content/repositories/releases (but use 'snapshots' instead of 'releases' if you are deploying a snapshot). The host name is the same as the Nexus server that I messed with above.
* Click 'advanced' on the right side of the screen.
* Enter 'nexus' for the id.
* Click 'ok' and it should deploy.

Note that all the 'artifacts' created with the Maven build will be deployed. This might include 'sources', 'test-jar' and 'test-sources'. Adding the 'test-jar' is done with an option on the maven jar plugin. The other two are don with options on the maven sources plugin.

No comments:

Post a Comment