Travis CI and Maven deploy
A simple way to set up Travis CI and Apache Maven to properly deploy snapshots into a maven repository.
The first step is to write a proper pom.xml
that allows for the deployment of snapshots, without signing it.
The gist bellow shows part of maven build files that is set up to deploy on the sonatype oss repository. By default, the deploy command will deploy the snapshot. If the release profile is active then the project artifacts will be signed and deploy to the release repository. You can find more information here.
The second step is to define the server credentials on Travis CI. It can be done via your Travis repository environment variables. Just go to the settings tab and choose the subtab Environment Variables
By default the variables you define here will be secure, and won't be shown in the build log.
So let's define two properties:
OSSRH_USER=<yourusername>
OSSRH_PASS=<yourpass>
AT this point, there is one last things to do; set up a .travis.yml
in your repository.
In this configuration, we create a maven settings.xml
in which we set the username and password for our server of id ossrh
. The username and password are actually in the environment variable we define earlier. The last step is to call mvn deploy
with this settings.
In this configuration those steps will be executed after the build has been successful and the test has pass.
You can have a look at a build with a similar configuration here.
Comments
Post a Comment