forked from echo3/echo3extras
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automatic deployment of snapshots to Sonatype by Travis-CI
Snapshots are deployed to the Sonatype Maven repository after every successful Travis-CI test build, analogous to echo3. Resolves echo3#12
- Loading branch information
Showing
3 changed files
with
82 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,15 @@ | ||
language: java | ||
language: java | ||
|
||
# Snapshot deployment to Sonatype Maven repository | ||
# The password is encrypted using "travis encrypt -r echo3/echo3extras SONATYPE_PASSWORD=password" | ||
# and only decrypted and set as environment variable by travis-ci if the build runs in the context of | ||
# the echo3/echo3extras github repository. | ||
|
||
env: | ||
global: | ||
- SONATYPE_USERNAME=bschmid | ||
- secure: "WkgVn7wbMe7C1KKAFZrvy2BR2eZZ6Bnv1/BPJFHOI+u172wnFPX5FDyjZQiU9xipocnWfa5MZCCpyKBJrNDnWEVlM75bZG6Xpq+yu3tbZgxyNZ3JLxU6a7m5OJo4XjhBiVbX7b+BmD5qHCO5CTgxZIJbKIz0ToUU+ALLcdVlsS8=" | ||
|
||
after_success: | ||
- python resource/travis-ci/addServer.py | ||
- ant travis.mvn.snapshot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/usr/bin/env python | ||
""" | ||
Add sonatype snapshot server and credentials to ~/.m2/settings.xml | ||
Username and password are passed in by travis-ci as environment | ||
variables. | ||
""" | ||
import sys | ||
import os | ||
import os.path | ||
import xml.dom.minidom | ||
|
||
if os.environ["TRAVIS_SECURE_ENV_VARS"] == "false": | ||
print "no secure env vars available, skipping deployment" | ||
sys.exit() | ||
|
||
homedir = os.path.expanduser("~") | ||
|
||
m2 = xml.dom.minidom.parse(homedir + '/.m2/settings.xml') | ||
settings = m2.getElementsByTagName("settings")[0] | ||
|
||
serversNodes = settings.getElementsByTagName("servers") | ||
if not serversNodes: | ||
serversNode = m2.createElement("servers") | ||
settings.appendChild(serversNode) | ||
else: | ||
serversNode = serversNodes[0] | ||
|
||
sonatypeServerNode = m2.createElement("server") | ||
sonatypeServerId = m2.createElement("id") | ||
sonatypeServerUser = m2.createElement("username") | ||
sonatypeServerPass = m2.createElement("password") | ||
|
||
idNode = m2.createTextNode("sonatype-nexus-snapshots") | ||
userNode = m2.createTextNode(os.environ["SONATYPE_USERNAME"]) | ||
passNode = m2.createTextNode(os.environ["SONATYPE_PASSWORD"]) | ||
|
||
sonatypeServerId.appendChild(idNode) | ||
sonatypeServerUser.appendChild(userNode) | ||
sonatypeServerPass.appendChild(passNode) | ||
|
||
sonatypeServerNode.appendChild(sonatypeServerId) | ||
sonatypeServerNode.appendChild(sonatypeServerUser) | ||
sonatypeServerNode.appendChild(sonatypeServerPass) | ||
|
||
serversNode.appendChild(sonatypeServerNode) | ||
|
||
m2Str = m2.toxml() | ||
f = open(homedir + '/.m2/settings.xml', 'w') | ||
f.write(m2Str + '\n') | ||
f.close() |