How to push Maven artifact to Nexus through GitLab CI - maven

I am new to GitLab and Nexus. I am trying to create artifact and push it to Nexus repo. I am getting error while running a job. Could anyone please help.
[ERROR] The specified user settings file does not exist: /builds/<project path>.m2/settings.xml
Build is executing successfully. Failing in test stage. Also added Nexus URL, Username and Password in gitlab Variables.
Is there a way to move settings.xml to GitLab?
.gitlab-ci.yml
image: maven:3-jdk-8
variables:
MAVEN_CLI_OPTS: "-s .m2/settings.xml --batch-mode"
MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"
cache:
paths:
- .m2/repository/
- target/
stages:
- build
- test
- package
- deploy
build:
stage: build
script:
- mvn compile
test:
stage: test
script:
- mvn $MAVEN_CLI_OPTS test
- echo "The code has been tested"
package:
stage: package
script:
- mvn $MAVEN_CLI_OPTS package -Dmaven.test.skip=true
- echo "Packaging the code"
artifacts:
paths:
- target/*.war
only:
- master
deploy:
stage: deploy
script:
- mvn $MAVEN_CLI_OPTS deploy -Dmaven.test.skip=true
- echo "installing the package in local repository"
only:
- master
pom
<distributionManagement>
<repository>
<id>nexus-releases</id>
<url>http://localhost:8081/repository/maven-releases/</url>
</repository>
</distributionManagement>
settings.xml
<server>
<id>nexus-releases</id>
<username>username</username>
<password>pass</password>
</server>
</servers>
<mirrors>
<mirror>
<id>central</id>
<name>central</name>
<url>http://localhost:8081/repository/maven-central/</url>
<mirrorOf>*</mirrorOf>
</mirror>

Related

How to access Maven dependency from Github Packages on a Github Actions workflow?

My build is working locally by using a User + PAT (personal access token) directly on the pom.xml <repository> element:
<repository>
<id>github</id>
<name>GitHub Packages</name>
<url>https://[USER]:[PAT]#maven.pkg.github.com/myaccount/myrepo</url>
</repository>
Downloaded from github:
https://[USER]:[PAT]#maven.pkg.github.com/myaccount/myrepo/org/springframework/flex/spring-flex-core/1.6.1.BUILD-SNAPSHOT/maven-metadata.xml
(796 B at 592 B/s)
I have no settings.xml configured.
However, it is breaking on a Github Actions workflow:
Warning: Could not transfer metadata
org.springframework.flex:spring-flex-core:1.6.1.BUILD-SNAPSHOT/maven-metadata.xml
from/to github (***maven.pkg.github.com/myaccount/myrepo):
Authentication failed for
https://maven.pkg.github.com/myaccount/myrepo/org/springframework/flex/spring-flex-core/1.6.1.BUILD-SNAPSHOT/maven-metadata.xml 401 Unauthorized
Failed to collect dependencies at org.springframework.flex:spring-flex-core:jar:1.6.1.BUILD-SNAPSHOT: Failed to read artifact descriptor for org.springframework.flex:spring-flex-core:jar:1.6.1.BUILD-SNAPSHOT
My workflow is like this:
steps:
- uses: actions/checkout#v2
- name: Set up JDK 1.8
uses: actions/setup-java#v1
with:
java-version: 1.8
- name: Cache Maven packages
uses: actions/cache#v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Build with Maven
run: mvn -B package --file dev/server/pom.xml
Why does it break on Github workflow?
Based on your question I suppose:
You have maven project deployed in GitHub Package, we call it library
You have another maven project which use the library package as a dependency in its pom.xml, we call this project as your app
You want to add automate build workflow using the GitHub Actions in app repository
If your library is a public package even, currently unfortunately the GitHub dose not support unauthorized access from maven for public packages. Therefore, you should do as follow:
First of all, you need to generate a PAT access token with package-read access in your profile setting, in developer setting subsection:
Go to setting section of your app repository, and in the subsection of Secrets create two environment secrets called USER_NAME which the value contains your GitHub username (or username of the owner of library package); and ACCESS_TOKEN point to the value of PAT token which created in previous step.
Now, create a maven-settings.xml in the app repository, for example you can create it, along side your workflow.yml file. the file contains:
<?xml version="1.0" encoding="UTF-8"?>
<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">
<activeProfiles>
<activeProfile>github</activeProfile>
</activeProfiles>
<profiles>
<profile>
<id>github</id>
<repositories>
<repository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
</repository>
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/owner_username/package_name</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
</profile>
</profiles>
<servers>
<server>
<id>github</id>
<username>${env.USER_NAME}</username>
<password>${env.ACCESS_TOKEN}</password>
</server>
</servers>
</settings>
And, finally use these setting file, in the workflow when run the maven command. for example the workflow.yaml file can contain:
name: Java CI with Maven
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- name: Set up JDK 8
uses: actions/setup-java#v2
with:
java-version: '8'
distribution: 'adopt'
- name: Build with Maven
run: mvn -s $GITHUB_WORKSPACE/.github/workflows/maven-settings.xml -B package --file pom.xml
env:
USER_NAME: ${{ secrets.USER_NAME }}
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
You need to use the GITHUB_TOKEN for actions.
See here: https://docs.github.com/en/packages/guides/configuring-apache-maven-for-use-with-github-packages#authenticating-to-github-packages
To authenticate using a GitHub Actions workflow: For package registries (PACKAGE-REGISTRY.pkg.github.com), you can use a GITHUB_TOKEN.
name: Java CI with Maven
on:
push:
branches: [ maven ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- name: Set up JDK 1.8
uses: actions/setup-java#v1
with:
java-version: 1.8
- name: Build core with Maven
...
- name: Publish package core
run: mvn --batch-mode deploy --file myproject.core/pom.xml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Maven build with Github Actions - Couldn't not resolve dependencies

I'm struggling a little bit with Github actions.
I'm trying to build a project with Maven using Github actions. The project contains a dependency located in a repo within the same org.
I created a PAT with read/write privileges and wrote the following script:
# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created
# Added personal token
name: Maven Deploy
on:
push:
branches: develop
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- name: Set up JDK 1.8
uses: actions/setup-java#v1
with:
java-version: 1.8
server-id: github
- name: Build with Maven
run: mvn -B package --file DynamoDB\ Service/pom.xml
env:
MENADEX_USERNAME: my_username
MENADEX_TOKEN: xxxxxxxxxxxxx
- name: Publish package
run: mvn deploy -f DynamoDB\ Service/pom.xml -s $GITHUB_WORKSPACE/DynamoDB\ Service/settings.xml
env:
MENADEX_USERNAME: my_username
MENADEX_TOKEN: xxxxxxxxxxxxxxxxxxxxxx
Github keeps complaining it couldn't find the artifact related to the dependency.
Settings.xml
<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
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<activeProfiles>
<activeProfile>github</activeProfile>
</activeProfiles>
<profiles>
<profile>
<id>github</id>
<repositories>
<repository>
<id>Common</id>
<name>GitHub Menadex Apache Maven Packages</name>
<url>https://maven.pkg.github.com/Menadex/Ad360CommonObjects</url>
</repository>
</repositories>
</profile>
</profiles>
<servers>
<server>
<id>github</id>
<username>${env.MENADEX_USERNAME}</username>
<password>${env.MENADEX_TOKEN}</password>
</server>
</servers>
</settings>
This is what I keep receiving:
[ERROR] Failed to execute goal on project dynamodb: Could not resolve dependencies for project com.ad360:dynamodb:jar:1.0.0-SNAPSHOT: Could not find artifact com.ad360:common:jar:1.0.0-SNAPSHOT -> [Help 1]
210
[ERROR]
211
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
212
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
213
[ERROR]
214
[ERROR] For more information about the errors and possible solutions, please read the following articles:
215
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
216
##[error]Process completed with exit code 1.
Also, I see that the newly created PAT was never touched. (In admin sections, it says 'never used').

How to install a package hosted by GitHub Packages with GitHub Actions

I deployed a Maven package to github according to these instructions.
https://help.github.com/en/github/managing-packages-with-github-packages/configuring-apache-maven-for-use-with-github-packages#installing-a-package
This worked.
Now I am installing a second Maven project that depends on the package that I just deployed to the github registry. I keep getting this error.
Error:
The POM for com.xxxxxxx:0.8.6 is missing, no dependency information available github packages
Failure to find com.xxxxxxx.xxxxxxx:jar:7.7 in https://repo.maven.apache.org/maven2
The install should not be searching for the dependency in repo.maven.apache.org. It should be searching in the github repository - where this dependency lives.
According to github's documentation [https://help.github.com/en/github/managing-packages-with-github-packages/using-github-packages-with-github-actions#installing-a-package-using-an-action] there is a way to install packages hosted by GitHub Packages through GitHub Actions that "requires minimal configuration or additional authentication, by using the GITHUB_TOKEN." However, that document does not explain how to achieve this. How do I need to update a github yaml workflow file to use a github package in an action?
Here is my .m2/settings.xml file...
<?xml version="1.0" encoding="UTF-8"?>
<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">
<localRepository />
<interactiveMode />
<usePluginRegistry />
<offline />
<pluginGroups />
<servers>
<server>
<id>github</id>
<username>myGithubUsername</username>
<password>GithubPersonalAccessToken</password>
</server>
</servers>
<mirrors />
<proxies />
<profiles>
<profile>
<id>github</id>
<repositories>
<repository>
<id>github</id>
<name>GitHub myGithubUsername Apache Maven Packages</name>
<url>https://maven.pkg.github.com/myGithubUsername /nameOfGithubRepositoryContainingTheMavenPackageIAmIncluding</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles />
</settings>
And here is where I reference the package in the pom.xml file of the 2nd project I am attempting to install.
<dependency>
<groupId>com.the organization name</groupId>
<artifactId>the package name</artifactId>
<version>0.8.6</version>
</dependency>
Finally, here is my yaml file for the github action.
name: BuildOnWikiEdit
on:
gollum:
branches:
- '*'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v1
- name: Run a one-line script
run: echo Hello, world!
- name: Run a multi-line script
run: |
echo Add other actions to build,
echo test, and deploy your project.
- name: Build
run: mvn install
You have to create settings.xml during your workflow. So, either manually create this file or use existing action from Marketplace.
Option 1:
- name: 'Create settings.xml'
run: |
touch ~/.m2/settings.xml
echo '<settings><servers><server><id>github</id><username>${{ secrets.GITHUB_USERNAME }}</username><password>${{ secrets.GITHUB_PASSWORD }}</password></server></servers></settings>' > ~/.m2/settings.xml
- name: Build
run: mvn install
Option 2:
- name: 'Create settings.xml'
uses: whelk-io/maven-settings-xml-action#v4
with:
servers: '[{"id": "github", "username": "${{ secrets.GITHUB_USERNAME }}", "password": "${{ secrets.GITHUB_PASSWORD }}"}]'
- name: Build
run: mvn install
Personally I use option 2 on my project.

deploy to Github Package Registry from Github Action

I would like to deploy to a GitHub Package Registry from a GitHub Action of a public repo.
I have a yml file for a workflow:
name: My CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v1
- name: Install dependencies
run: lein deps
- name: Run tests
run: lein test
- name: Generate pom
run: lein pom
- name: Deploy
run: mvn deploy
I use Leiningen to build the project and generate a POM file. Then I would like to use Maven to deploy the artifact to the GitHub Package Registry.
This fails on the Deploy command (I have replaced personal information with ...):
[WARNING] Could not transfer metadata ... from/to github (https://maven.pkg.github.com/.../...): Not authorized
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 19.343 s
[INFO] Finished at: 2019-08-29T13:08:42Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project ...: Failed to retrieve remote metadata .../maven-metadata.xml: Could not transfer metadata ... from/to github (https://maven.pkg.github.com/.../...): Not authorized -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
##[error]Process completed with exit code 1.
I see that authentication failed. I have also tried with this step with the same results:
run: mvn deploy -Dserver.username=... -Dserver.password=${{ secrets.GITHUB_TOKEN }} -DskipTests
I do not want to supply username/password or token as this is a public repository. Is there a way to publish anyway?
Thanks!
To make it work, you need to do two things:
Add the following to your pom.xml:
<distributionManagement>
<repository>
<id>github</id>
<name>GitHub OWNER Apache Maven Packages</name>
<url>https://maven.pkg.github.com/OWNER/REPOSITORY</url>
</repository>
</distributionManagement>
source: https://help.github.com/en/articles/configuring-apache-maven-for-use-with-github-package-registry#publishing-a-package
Setup a Maven settings file with the username/password from within your build action.
In my case I did something like this:
name: Java CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v1
- name: Set up JDK 1.8
uses: actions/setup-java#v1
with:
java-version: 1.8
- name: Deploy to Github Package Registry
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mkdir ~/.m2
echo "<settings><servers><server><id>github</id><username>OWNER</username><password>${GITHUB_TOKEN}</password></server></servers></settings>" > ~/.m2/settings.xml
mvn deploy
Unfortunately, I don't think you can pass the username/password as arguments to Maven and so you need to set up the settings file instead.
source: Is it possible to pass a password in Maven Deploy in the command line?
Lastly, I confirm that this only works for non-SNAPSHOT artifacts. When I try deploying a SNAPSHOT version it fails with a 400 error as described.
TL;DR: Just commit the following to .github/workflows/mavenpublish.yml and create a release via the GitHub web page to trigger the process:
name: Maven Package
on:
release:
types: [created]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- name: Set up JDK 1.8
uses: actions/setup-java#v1
with:
java-version: 1.8
- name: Deploy to Github Package Registry
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mkdir -p ~/.m2
echo "<settings><servers><server><id>gh</id><username>$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $1}')</username><password>\${env.GITHUB_TOKEN}</password></server></servers></settings>" > ~/.m2/settings.xml
REPO="gh::default::https://maven.pkg.github.com/${GITHUB_REPOSITORY}"
mvn deploy -DaltReleaseDeploymentRepository="${REPO}" -DaltSnapshotDeploymentRepository="${REPO}"
Some more info:
I have built the same thing before for Jenkins and can tell you that you don't need to create a settings.xml nor adapt your pom.xml in your repo.
You can even avoid writing your GitHub Token into the settings.xml (which is more secure).
Also, you don't need to manually add your repo and username, these can be read from the environment.
If you want it to build on push, just change the lines behind on: to [push].
Here`s a real-life example.
There is an easier way in 2020.
First, add distribution configuration to your pom.xml:
<distributionManagement>
<repository>
<id>github</id>
<name>GitHub OWNER Apache Maven Packages</name>
<url>https://maven.pkg.github.com/OWNER/REPOSITORY</url>
</repository>
</distributionManagement>
The id must be github.
Second, use actions/setup-java#v1 in action
steps:
- uses: actions/checkout#v2
- uses: actions/setup-java#v1
with:
java-version: 1.8
- name: Publish to GitHub Packages
env:
GITHUB_TOKEN: ${{ github.token }}
run: mvn deploy
I had a similar issue for my project.
Every time I ran mvn deploy, it failed with:
Could not transfer metadata ... from/to github (https://maven.pkg.github.com/.../...): 400
However, on a whim, I changed the version number of my project from 0.0.3-SNAPSHOT to 0.0.4 and after that, it worked.
Maybe it will work for you too.
Well, According to:
maven command line how to point to a specific settings.xml for a single command?
GitHub package registry as Maven repo - trouble uploading artifact
I think you could simply do like this:
Add below to your workflow
- name: Deploy to Github Package Registry
env:
GITHUB_USERNAME: x-access-token
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run:
mvn --settings settings.xml deploy
And then add settings.xml to your project
<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">
<activeProfiles>
<activeProfile>github</activeProfile>
</activeProfiles>
<profiles>
<profile>
<id>github</id>
<repositories>
<repository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>github</id>
<name>GitHub OWNER Apache Maven Packages</name>
<url>https://maven.pkg.github.com/OWNER </url>
</repository>
</repositories>
</profile>
</profiles>
<servers>
<server>
<id>github</id>
<username>${env.GITHUB_USERNAME}</username>
<password>${env.GITHUB_TOKEN}</password>
</server>
</servers>
</settings>
It works for me, I hope this will help.

travis gitflow java maven workflow

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
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.

Resources