- encrypt your sonatype oss password with
travis encrypt -r user/repo SONATYPE_PASSWORD=pass
- put addServer.py somewhere in your repository
- add the relevant lines to your .travis.yml
Deployment will only happen when the build was successful and the encrypted variables are available (= no deployment for pull requests etc.). If the deployment itself was unsuccessful, then the build still passes.
If you only want to deploy for certain branches, use shell scripting like:
after_success:
- "[[ $TRAVIS_BRANCH == \"master\" ]] && { python travis/addServer.py; mvn clean deploy --settings ~/.m2/mySettings.xml; };"
Warning: This will deploy multiple times if you use the matrix functionality, see the issue.
you can remove the need for addServer.py - I simply checked in a settings.xml with my project using maven property variables
then use the same
travis encrypt -r <user/repo> SONATYPE_PASSWORD=pass --add
command to add those env variables to .travis.ymland finally run the deploy using
mvn deploy --settings settings.xml