Maven Deploy Using Travis

I have recently updated my Organizational Super POM to start doing SNAPSHOT deployments on my `master` branch and release builds on tags using Travis for my open source projects. This is based off the work on Automatically publishing to GitHub Pages where I just have something more complicated than a simple token.


  1. Create the GnuPG, SSH keys and settings.xml configuration you need to deploy.
  2. tar them up to deploy-keys.tar ensuring that the directory structure is intact.
  3. `travis encrypt-file deploy-keys.tar –add`
  4. In travis.xml, after the `- openssl …` in `before_install:` add
    `tar xf deploy-keys.tar -C $HOME`
  5. Create a `deploy` section
    - provider: script
      skip_cleanup: true
      script: mvn deploy site-deploy
        branch: master
    - provider: script
      skip_cleanup: true
      script: printf 'scm.tag=%1s\nscm.url=scm:git:' "${TRAVIS_TAG}"
        "${TRAVIS_REPO_SLUG}" > && mvn release:perform
        tags: true
  6. Check in and commit deploy-keys.tar.enc and .travis.yml
  7. DO NOT check-in nor commit deploy-leys.enc, best you add it to .gitignore

Creating a release

To create a release, run `mvn release:perform` which will create a new commit with for the release versions and a tag that will trigger the Travis build.

An example of this is in