0
votes

I all,

working on a java project hosted on github. I would like to push the code directly to sonatype on development and master branch.

currently only the develop branch works because I skipped the gpg signing

I use the setting.xml in .travis folder with my credentials

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      http://maven.apache.org/xsd/settings-1.0.0.xsd">
    <servers>
        <server>
            <!-- Maven Central Deployment -->
            <id>ossrh</id>
            <username>${env.SONATYPE_USERNAME}</username>
            <password>${env.SONATYPE_PASSWORD}</password>
        </server>
    </servers>
    <profiles>
        <profile>
            <id>ossrh</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <gpg.executable>gpg</gpg.executable>
                <gpg.passphrase>${env.GPG_PASSPHRASE}</gpg.passphrase>
            </properties>
        </profile>
    </profiles>
</settings>

my travis.yml looks like this:

language: java
jdk:
  - oraclejdk8

script:
 - mvn --settings .travis/settings.xml clean verify

deploy:
 -
  provider: script
  script:
   - mvn --settings .travis/settings.xml deploy -D gpg.skip -P release
  on:
    branch: develop
 -
  provider: script
  script:
   - mvn --settings .travis/settings.xml org.codehaus.mojo:versions-maven-plugin:2.3:set -D newVersion=$TRAVIS_TAG -P release
   - .travis/gpg.sh
   - mvn clean deploy --settings .travis/settings.xml -D skipTests=true --batch-mode --update-snapshots -P release
  on:
    tags: true

my release profile include the deploy plugins needed.

I am getting an error when I push a tag/release (like 0.0.2). I expect this to deploy a release using the tag.

The develop branch works fine and the snapshot is deployed to sonatype repo correctly.

https://github.com/effectus-io/effectus-parent

thanks in advance

here is the travis log error.

The command "mvn --settings .travis/settings.xml clean verify" exited with 0. Skipping a deployment with the script provider because this branch is not permitted dpl.0 Fetching: dpl-1.8.31.gem (100%)Fetching: dpl-1.8.31.gem (100%) Successfully installed dpl-1.8.31 1 gem installed dpl.1 Installing deploy dependencies !!! Script support is experimental !!! Preparing deploy Cleaning up git repository with `git stash --all`. If you need build artifacts for deployment, set `deploy.skip_cleanup: true`. See https://docs.travis-ci.com/user/deployment/#Uploading-Files. No local changes to save dpl.3 Deploying application No stash found. /home/travis/.rvm/gems/ruby-1.9.3-p551/gems/dpl-1.8.31/lib/dpl/cli.rb:54:in `system': wrong first argument (ArgumentError) from /home/travis/.rvm/gems/ruby-1.9.3-p551/gems/dpl-1.8.31/lib/dpl/cli.rb:54:in `shell' from /home/travis/.rvm/gems/ruby-1.9.3-p551/gems/dpl-1.8.31/lib/dpl/provider/script.rb:18:in `push_app' from /home/travis/.rvm/gems/ruby-1.9.3-p551/gems/dpl-1.8.31/lib/dpl/provider.rb:146:in `block in deploy' from /home/travis/.rvm/gems/ruby-1.9.3-p551/gems/dpl-1.8.31/lib/dpl/cli.rb:41:in `fold' from /home/travis/.rvm/gems/ruby-1.9.3-p551/gems/dpl-1.8.31/lib/dpl/provider.rb:146:in `deploy' from /home/travis/.rvm/gems/ruby-1.9.3-p551/gems/dpl-1.8.31/lib/dpl/cli.rb:32:in `run' from /home/travis/.rvm/gems/ruby-1.9.3-p551/gems/dpl-1.8.31/lib/dpl/cli.rb:7:in `run' from /home/travis/.rvm/gems/ruby-1.9.3-p551/gems/dpl-1.8.31/bin/dpl:5:in `<top (required)>' from /home/travis/.rvm/gems/ruby-1.9.3-p551/bin/dpl:23:in `load' from /home/travis/.rvm/gems/ruby-1.9.3-p551/bin/dpl:23:in `<main>' failed to deploy

1
Not entirely sure how to help you, but browsing DPL I did see this: github.com/travis-ci/dpl/pull/466 , you might take a look there and see if any of the commits give you clues on how to get it working. - DarthHater

1 Answers

0
votes

after much trial and error I realised it is just too much work to try and sign release on travis, there is no good support and that is a shame.

My alternative solution is to use bintray -> https://bintray.com/ it provides a release repo with automate gpg signing of the jars. It also sync with sonatype so I believe this is a complete solution using maven.

in the pom I automated the versioning with the plugin -> https://github.com/effectus-io/effectus-parent/blob/master/pom.xml#L299 notice I do not commit from travis!

I kept the snapshot going directly into sonatype for simplicity ->https://github.com/effectus-io/effectus-parent/blob/master/.travis.yml#L34

you can see my workflow here -> https://github.com/effectus-io/effectus-parent/releases/tag/0.0.10

using gitflow, normal commit to develop branch will automatically push a snapshot to sonatype. Using a release (after tagging) will trigger a build and reversioning using the maven version plugin wich will remove the SNAPSHOT from the pom(s) and deploy to bintray.