- 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.
Thanks a lot for the information - I found them very helpful!
I may add 2 suggestions:
-DskipTests=true
to themvn
commandline, as tests usually ran beforesonatype-nexus-snapshots
in the Python script might be changed, if you renamed the SNAPSHOT repository differently in your parent POM. E.g. in my parent POM XML I have the following lines:therefore I needed to modify line 28 of the script to: