- 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.
@eeichinger I like your approach - it's basically much simpler and works also nicely :)
The only suggestion for improvement I have is to change the deploy command to
so that tests are not executed (again) and to use Maven Batch mode (-B)
@edit: maybe adding a special Maven profile might also be a good idea in certain cases (add e.g.
-P travis-deploy
)