mbohun
9/4/2014 - 7:53 AM

ala-build.md

#!/bin/bash

#default to snapshot
maven_repo="nectar-nexus-repo-snapshot"
 
# if we can't find -SNAPSHOT in app.version then reset maven repo to release
grep 'app\.version' application.properties | grep -q "\-SNAPSHOT$"
if [ "$?" = "1" ]; then maven_repo="nectar-nexus-repo-release"; fi

echo $maven_repo

##Beware of grails maven publisher/release plugin misleading error messages Basically the real error/problem/cause (examples of real errors are something like: wrong password or username, an attempt to redeploy into a repository that is configured with redeploy=false, etc) is completely hidden behind layers and layers of crap...

###Examples

####example 00

bash-3.2$ grails prod maven-deploy --repository=nectar-nexus-repo-test
 ...
[ala-hub] No external configuration file defined.
[ala-hub] (*) grails.config.locations = []
| Done creating WAR target/ala-hub-1.4-SNAPSHOT.war
| Using configured username and password from grails.project.repos.nectar-nexus-repo-test....
| Error Error deploying artifact: Error deploying artifact 'au.org.ala:ala-hub:war': Error deploying artifact: Failed to transfer file: http://130.56.249.242/nexus/content/repositories/releases/au/org/ala/ala-hub/1.4-SNAPSHOT/ala-hub-1.4-20140918.033423-1.war. Return code is: 400
| Error Have you specified a configured repository to deploy to (--repository argument) or specified distributionManagement in your POM?
  • reported error: Error deploying artifact ... HTTP return code 400
  • real problem: an attempt to deploy a SNAPSHOT into a release repo or vice versa

####example 01

| Done creating WAR target/dashboard-0.2-SNAPSHOT.war
POM generated: /Users/hor22n/src/dashboard_mbohun.git/target/pom.xml
Error deploying artifact: Error deploying artifact 'au.org.ala:dashboard:war': Error deploying artifact: Failed to transfer file: http://130.56.249.242/nexus/content/repositories/snapshots/au/org/ala/dashboard/0.2-SNAPSHOT/dashboard-0.2-20140924.050741-1.war. Return code is: 401
Have you specified a configured repository to deploy to (--repository argument) or specified distributionManagement in your POM?
Maven deploy complete.
  • reported error: Error deploying artifact ... HTTP return code 401
  • real problem: dashboard is an older grails app (grails 2.2.4), and the grails (publisher/release) maven plugin prior to grails 2.3 (< 2.3)requires the repository info to be in format:
grails.project.dependency.distribution = {
  remoteRepository(id:"nectar-nexus-repo-snapshot", url:"http://130.56.249.242/nexus/content/repositories/snapshots") {
    authentication username: System.getenv("TRAVIS_DEPLOY_USERNAME"), password: System.getenv("TRAVIS_DEPLOY_PASSWORD")
  }

  remoteRepository(id:"nectar-nexus-repo-release",  url:"http://130.56.249.242/nexus/content/repositories/releases") {
    authentication username: System.getenv("TRAVIS_DEPLOY_USERNAME"), password: System.getenv("TRAVIS_DEPLOY_PASSWORD")
  }
}

(instead of the newer format used by grails 2.3 and higher (>=2.3)):

grails.project.repos.'nectar-nexus-repo-snapshot'.url = "http://130.56.249.242/nexus/content/repositories/snapshots/"
grails.project.repos.'nectar-nexus-repo-snapshot'.username = System.getenv("TRAVIS_DEPLOY_USERNAME")
grails.project.repos.'nectar-nexus-repo-snapshot'.password = System.getenv("TRAVIS_DEPLOY_PASSWORD")

grails.project.repos.'nectar-nexus-repo-release'.url = "http://130.56.249.242/nexus/content/repositories/releases/"
grails.project.repos.'nectar-nexus-repo-release'.username = System.getenv("TRAVIS_DEPLOY_USERNAME")
grails.project.repos.'nectar-nexus-repo-release'.password = System.getenv("TRAVIS_DEPLOY_PASSWORD")

NOTE: maven release plugin with grails 2.4 and higher (>=2.4) accepts and works with BOTH (old AND new) ~/.grails/settings.groovy file formats.

####example-02 HTTP error 500 (Internal Server Error) reported when sonatype nexus run out of disk space

diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..eb6421c
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,25 @@
+language: groovy
+
+jdk:
+  - oraclejdk7
+
+branches:
+  only:
+    - master
+
+before_install:
+- rm -rf ~/.gvm
+- curl -s get.gvmtool.net > ~/install_gvm.sh
+- chmod 775 ~/install_gvm.sh
+- ~/install_gvm.sh
+- echo "gvm_auto_answer=true" > ~/.gvm/etc/config
+- source ~/.gvm/bin/gvm-init.sh
+- gvm install grails $GRAILS_VERSION || true
+
+script: "grails clean && grails upgrade --non-interactive && grails refresh-dependencies --non-interactive && grails prod maven-deploy --repository=nectar-nexus-repo-snapshot"
+
+env:
+  global:
+    - GRAILS_VERSION=2.3.11
+    - secure: "zq9ESeT28Bd9uMYzPXvIaF4dP5C4iHKfvco/GGBWIZUMFJi559LJ61Ddaln10GxuUTWy9s4Xm18KIj6t7u9S6ly+dJ2PgKOavxilTQ3rCF9bCPQ0ylRMqce+ecFoP2T2S8KjHbMUA0+mC+7SCHEHmJZxuwyeCzE8nMpkJkPaQLU="
+    - secure: "v0vb6dKg4CMEeLzlY33wXt+xgHUW4C9E5peHiEQxswUtgGTh95c2xW4OiAJ+dDUjvuu5mKMqLInX66JlLEYq++X1jMY2lSsN/uufCHTn72Jk6wBFZZMNlpa1U5KRcc4OXDGc7dlA/JApjlwlT53Fe9ItPma/VCSlXJd8Ea+hmmQ="
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..8b9b172
--- /dev/null
+++ b/README.md
@@ -0,0 +1,3 @@
+#### ala-hub
+
+ALA version of the hub app   [![Build Status](https://travis-ci.org/mbohun/ala-hub.svg?branch=master)](https://travis-ci.org/mbohun/ala-hub)
diff --git a/grails-app/conf/BuildConfig.groovy b/grails-app/conf/BuildConfig.groovy
index 64dcec4..8d6ea65 100644
--- a/grails-app/conf/BuildConfig.groovy
+++ b/grails-app/conf/BuildConfig.groovy
@@ -67,3 +67,11 @@ grails.project.dependency.resolution = {
         runtime ":ala-web-theme:0.8.1"
     }
 }
+
+grails.project.repos.'nectar-nexus-repo-snapshot'.url = "http://130.56.249.242/nexus/content/repositories/snapshots/"
+grails.project.repos.'nectar-nexus-repo-snapshot'.username = System.getenv("TRAVIS_DEPLOY_USERNAME")
+grails.project.repos.'nectar-nexus-repo-snapshot'.password = System.getenv("TRAVIS_DEPLOY_PASSWORD")
+
+grails.project.repos.'nectar-nexus-repo-release'.url = "http://130.56.249.242/nexus/content/repositories/releases/"
+grails.project.repos.'nectar-nexus-repo-release'.username = System.getenv("TRAVIS_DEPLOY_USERNAME")
+grails.project.repos.'nectar-nexus-repo-release'.password = System.getenv("TRAVIS_DEPLOY_PASSWORD")
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..0f5872f
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,25 @@
+language: groovy
+
+jdk:
+- oraclejdk7
+
+branches:
+  only:
+  - master
+
+before_install:
+- rm -rf ~/.gvm
+- curl -s get.gvmtool.net > ~/install_gvm.sh
+- chmod 775 ~/install_gvm.sh
+- ~/install_gvm.sh
+- echo "gvm_auto_answer=true" > ~/.gvm/etc/config
+- source ~/.gvm/bin/gvm-init.sh
+- gvm install grails $GRAILS_VERSION || true
+
+script: mkdir -p ~/.grails; cp travis_grails_settings.groovy ~/.grails/settings.groovy; maven_repo="nectar-nexus-repo-snapshot"; grep 'app\.version' application.properties | grep -q "\-SNAPSHOT$"; if [ "$?" = "1" ]; then maven_repo="nectar-nexus-repo-release"; fi; grails clean && grails upgrade --non-interactive && grails refresh-dependencies --non-interactive && grails prod maven-deploy --repository=$maven_repo
+
+env:
+  global:
+  - GRAILS_VERSION=2.3.8
+  - secure: "QAEefhMWV/lKTPcIHq8AY52DWlEXLp4DxIApP0w1RGYDHf+UA0A/v6z32rRdTE+kuw63MAxzS+Vxi+WRJIm+zCm+ZVteT/MrrEfzDkNRy+Fzc7ej7fkeGmPD7lF7yZgBrGj+eLUAIAkKzIQElI6O2RmMBIuc2Tn0FskPTJZceZE="
+  - secure: "CPvVyaFjhPoeFe+JhiC+3vWNYxfdwW0dGhvhIbf2F+PUcFbmddjpe4gjp9U4l9prE3yNh0yXmn4hP+UTzRSl+/mucyk+CF1xdJ3ZR7rFJud3eRj7sfdQ/wjhYHzaCBWVvEqvP85D0Ur0BMkXu6dCrSldvs0h3tGRRHNa3ZrfBbU="
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..a504a86
--- /dev/null
+++ b/README.md
@@ -0,0 +1,3 @@
+#### alerts
+
+[![Build Status](https://travis-ci.org/mbohun/alerts.svg)](https://travis-ci.org/mbohun/alerts)
diff --git a/travis_grails_settings.groovy b/travis_grails_settings.groovy
new file mode 100644
index 0000000..ae14bb7
--- /dev/null
+++ b/travis_grails_settings.groovy
@@ -0,0 +1,7 @@
+grails.project.repos.'nectar-nexus-repo-snapshot'.url = "http://130.56.249.242/nexus/content/repositories/snapshots/"
+grails.project.repos.'nectar-nexus-repo-snapshot'.username = System.getenv("TRAVIS_DEPLOY_USERNAME")
+grails.project.repos.'nectar-nexus-repo-snapshot'.password = System.getenv("TRAVIS_DEPLOY_PASSWORD")
+
+grails.project.repos.'nectar-nexus-repo-release'.url = "http://130.56.249.242/nexus/content/repositories/releases/"
+grails.project.repos.'nectar-nexus-repo-release'.username = System.getenv("TRAVIS_DEPLOY_USERNAME")
+grails.project.repos.'nectar-nexus-repo-release'.password = System.getenv("TRAVIS_DEPLOY_PASSWORD")

##Intro The ALA applications/components can be divided into 3 diff groups/types according to the build system they use:

  • jenkins-mvn/maven - maven project, build with maven, deployed into a maven repo using hudons/jenkins maven plugin
  • grails-mvn - grails project, build with grails, deployed into a maven repo using grails maven plugin
  • jenkins-scp - grails project, build with grails, resulting .war scp into a maven repo using hudson/jenkins scp plugin
jenkins-mvn/mavengrails-mvnjenkins-scp
ala-casala-downloadsala-expert
ala-cas-clientala-hubapikey
ala-fieldguideala-soils2satbhl-demo-app :warning:
ala-loggerala-web-themebie-webapp2
ala-logger-servicealertsdashboard
ala-name-matchingamrin-hubecodata
ala-names-generatorappd-hubfieldcapture
analysis-serviceasbp-hubfieldcapture-hubs
bie-profileavh-hubfielddata
bie-servicebhl-ftindex-manageozatlas-proxy
biocache-jmsbiocache-hubsregions :warning:
biocache-storecollectorysandbox
layer-ingestionfielddata-proxysds-webapp2
layers-servicegeneric-hubsightings
layers-storeimage-servicespecimenbrowser
sensitive-speciesimages-client-plugintviewer
spatial-portalobis-hubuserdetails
ozcam-hubvolunteer-portal
specieslist-webappwebapi
tepapa-hub

NOTE: :warning: uses grails < 2.1 (as in no maven support before grails 2.1)

##What needs to be done? In order to add support for travis-ci.org we need to adjust the projects/component as follows:

###common steps This has to be done for each ALA project we want to add travis-ci.org support to. The order of these steps is important (as in you won't be able to encrypt/generate usernames/passwords for atlasoflivingaustralia/alerts before you enabled the project atlasoflivingaustralia/alerts in travis-ci.org)

  1. log into travis-ci.org with your github (atlasoflivingaustralia admin/owner) profile, and enable the project/component you want add travis support for, for example atlasoflivingaustralia/alerts
  2. Install the travis client, usually with: sudo gem install travis; this is required to encrypt env variables, files, etc. We want to encrypt our maven repo username/password for deployment from travis-ci.org into our maven repo-s, example:
git clone git@github.com:AtlasOfLivingAustralia/alerts.git alerts.git
cd alerts.git
travis2.0 encrypt -r AtlasOfLivingAustralia/alerts "TRAVIS_DEPLOY_USERNAME=someusername"
Please add the following to your .travis.yml file:

  secure: "DxzC7mcfOxW6xfV7kUi2qc1kSS/7RCqWw+YFqVxWGJsxPiHiGobKf6PlGDqo8KJgCzQR0apqgvr0bKO9CcRbuqfWNuSsRVf6odHcuvktqIiCznMs7tzbCk8xcu0suXBKrz1sgHphtze/Nt2idTFeLtX6rZ+svKs21kxb9yT2Ik="

travis2.0 encrypt -r AtlasOfLivingAustralia/alerts "TRAVIS_DEPLOY_PASSWORD=somepassword"
Please add the following to your .travis.yml file:

  secure: "XIODXD7cct/ruQ/bQ7i/gjhZbUhh8T/y7jZ8xkzQjuwggXm7DQhsWwfpONDjK+R1c2aSTFgBZVR6dSVoo/OIrTZhvmqfcfkYqalNxpqW+YGr/uy723srO0N0RYXJW+3AT2JnoT10SgktyKZMbBvJcGLvSkzr/sfhzDScA5vsoJY="

add the encrypted strings to your .travis.yml file env: section as described bellow. The rest of these steps is specific, depending on what type of project (jenkins-mvn, grails-mvn, jenkins-scp).

###jenkins-mvn/maven These projects/components are "ready to go". All that needs to be done, is the basic/standard support for travis:

  1. add/commit/push travis-maven-settings.xml file (same file format and purpose like ~/.m2/settings.xml) TODO: OR wget from a fileserver
  2. add/commit/push <distributionManagement> to your pom.xml file TODO: IF there is some other way to provide this info our life is going to be easier
  3. add/commit/push .travis file to the github project repo, see https://github.com/mbohun/ala-cas for a working example

working examples:

###grails-mvn These projects are "ready to go". All that needs to be done, is the basic/standard support for travis:

  1. take the "generic" grails .travis file (TODO: agree with Dave which is the best template/approach to use)

1.1 make sure to set the correct GRAILS_VERSION, for example: GRAILS_VERSION=2.3.11 (why we bother with this manually? can't i simply sed it out of application.properties file?)

  1. make sure your grails grails.project.groupId = "au.org.ala", this can be well hidden either in:
  • grails-app/conf/Config.groovy, or
  • grails-app/conf/BuildConfig.groovy, or
  • application.properties

working examples:

###jenkins-scp These projects needs to be 'mavenized' first in order to become the same as grails-mvn. grails supports maven since grails version 2.1.

  1. add grail release plugin to BuildConfig.groovy
  2. and follow grails-mvn steps to finish (TODO: naivite - in theory this should be the end, BUT)

working examples:

##Summary table

modulebuild sysjenkins build targetsdeployment
ala-casMaven 3.2.1clean install -DskipTests=true -ejenkins-mvn
ala-cas-clientMaven 3.2.1clean install -DskipTests=true -ejenkins-mvn
ala-downloadsGrails 2.3.8clean-all refresh-dependencies maven-install maven-deploygrails-mvn
ala-expertGrails 2.2.2"prod war target/expert.war"jenkins-scp
ala-fieldguideMaven 3.2.1clean install -DskipTests=truejenkins-mvn
ala-hubGrails 2.3.11refresh-dependencies "prod maven-install" "prod maven-deploy"grails-mvn
ala-loggerMaven 3.2.1clean install -DskipTests=truejenkins-mvn
ala-logger-serviceMaven 3.2.1clean install -DskipTests=truejenkins-mvn
ala-name-matchingMaven 3.2.1clean installjenkins-mvn
ala-names-generatorMaven 3.2.1clean installjenkins-mvn
ala-soils2satGrails 2.2.3?grails-mvn?
ala-web-themeGrails 2.3.11clean refresh-dependencies maven-deploygrails-mvn
alertsGrails 2.3.8refresh-dependencies "prod maven-install" "prod maven-deploy"grails-mvn
amrin-hubGrails 2.3.7refresh-dependencies "prod maven-install" "prod maven-deploy"grails-mvn
analysis-serviceMaven 3.2.1clean install -DskipTests=truejenkins-mvn
apikeyGrails 2.2.0"prod war target/apikey.war" --non-interactive"jenkins-scp
appd-hubGrails 2.3.7refresh-dependencies "prod maven-install" "prod maven-deploy"grails-mvn
asbp-hubGrails 2.3.7refresh-dependencies "prod maven-install" "prod maven-deploy"grails-mvn
avh-hubGrails 2.3.11refresh-dependencies "prod maven-install" "prod maven-deploy"grails-mvn
bhl-demo-appGrails 2.0.1?jenkins-scp
bhl-ftindex-manageGrails 2.2.3?grails-mvn?
bhl-ftindexerMaven 3.2.1?maven
bhl-solr-pluginMaven 3.2.1?maven
bie-profileMaven 3.2.1clean install -DskipTests=truejenkins-mvn
bie-serviceMaven 3.2.1clean install -DskipTests=truejenkins-mvn
bie-webapp2Grails 2.3.11"prod war target/bie-webapp2.war"BROKEN with grails publisher/release plugin, pom.xml creation failsjenkins-scp
biocache-hubsGrails 2.3.8clean refresh-dependencies "prod maven-deploy" "prod maven-install"grails-mvn
biocache-jmsMaven 3.2.1clean install -DskipTests=truejenkins-mvn
biocache-serviceMaven 3.2.1-e clean deploymaven
biocache-storeMaven 3.2.1clean deploy -e -DskipTests=true DUPLICATE deploy?maven,jenkins-mvn
collectoryGrails 2.3.8refresh-dependencies "prod maven-install" "prod maven-deploy"grails-mvn
dashboardGrails 2.2.4"prod war target/dashboard.war"jenkins-scp
ecodataGrails 2.2.1"prod war target/ecodata.war"jenkins-scp
fieldcaptureGrails 2.2.1clean "prod war target/fieldcapture.war"jenkins-scp
fieldcapture-hubsGrails 2.4.3clean refresh-dependencies "prod war target/fieldcapture-hub.war"jenkins-scp
fieldcapture-mobileandroid, iosTODO android/gradle?gradle?
fielddataGrails 2.1.1"prod war target/fielddata.war"jenkins-scp
fielddata-androidandroidTODO android/gradle?gradle?
fielddata-mobileandroid, iosTODO?
fielddata-proxyGrails 2.2.0?grails-mvn
generic-hubGrails 2.3.8refresh-dependencies "prod maven-install" "prod maven-deploy"grails-mvn
image-loaderMaven 3.2.1?maven
image-serviceGrails 2.3.11?grails-mvn?
image-tiling-agentMaven 3.2.1?maven
image-utilsMaven 3.2.1?maven
images-client-pluginGrails 2.3.11?grails-mvn?
layer-ingestionMaven 3.2.1clean install -DskipTests=truejenkins-mvn
layers-serviceMaven 3.2.1clean install -DskipTests=truejenkins-mvn
layers-storeMaven 3.2.1clean install -DskipTests=truejenkins-mvn
obis-hubGrails 2.3.7refresh-dependencies "prod maven-install" "prod maven-deploy"grails-mvn
ozatlasandroidandroid/phonegap?
ozatlas-androidandroidTODOTODO
ozatlas-proxyGrails-2.2.4"prod war target/mobileauth.war"jenkins-scp
ozcam-hubGrails 2.3.7refresh-dependencies "prod maven-install" "prod maven-deploy"grails-mvn
regionsGrails 1.3.7"prod war target/regions.war"jenkins-scp
sandboxGrails 2.2.4"prod war target/datacheck.war"jenkins-scp
sds-webapp2Grails 2.3.7"prod war target/sds-webapp2.war"jenkins-scp
sensitive-speciesMaven 3.2.1clean install -DskipTests=truejenkins-mvn
sightingsGrails 2.1.1"prod war target/sightings.war"jenkins-scp
spatial-loggerMaven 3.2.1?maven?
spatial-portalMaven 3.2.1clean installjenkins-mvn
specieslist-webappGrails 2.3.8refresh-dependencies "prod maven-install" "prod maven-deploy"grails-mvn
specimenbrowserGrails 2.2.2?jenkins-scp?
tepapa-hubGrails 2.3.7refresh-dependencies "prod maven-install" "prod maven-deploy"grails-mvn
tviewerGrails 2.1.2"prod war target/tviewer.war"jenkins-scp
userdetailsGrails 2.2.4"prod war target/userdetails.war"jenkins-scp
volunteer-portalGrails 2.3.11"prod war target/volunteer-portal.war"jenkins-scp
webapiGrails 2.3.8"prod war target/webapi.war" --non-interactive"jenkins-scp