TSK-528 now testing multiple databases simultaneously

This commit is contained in:
Mustapha Zorgati 2018-06-18 14:37:57 +02:00 committed by Holger Hagen
parent 8425ec32b4
commit ff6367477a
11 changed files with 375 additions and 374 deletions

View File

@ -1,42 +1,71 @@
language: java
jdk:
- oraclejdk8
services:
- docker
cache:
directories:
- $HOME/.m2
- web/node_modules
- web/dist
stages:
- Build
- Test
- "Release / Deploy"
env:
global:
- NODE_VERSION: 6
cache:
timeout: 604800 #1 week
directories:
- "$HOME/.m2"
- "web/node_modules"
before_install:
- nvm install $NODE_VERSION
- npm install -g @angular/cli >/dev/null 2>&1
- lib/deployment/change_version.sh -m "rest/ lib/ web/" -swarm lib/taskana-cdi/src/test/java/pro/taskana/TaskanaProducersTest.java
install:
- (cd web && npm install --no-progress && npm run build:prod)
&& mvn clean install -q -f lib/ -DskipTests=true -Dmaven.javadoc.skip=true -B
&& mvn clean install -q -f rest/ -DskipTests=true -Dmaven.javadoc.skip=true -B
before_script:
- NODE_VERSION=6
matrix:
- DB=H2
- DB=DB2_10_5
- DB=DB2_11_1
- DB=POSTGRES
stage: Test
script:
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
- sleep 3 # give xvfb some time to start
script:
- (cd web && npm run test)
&& mvn verify -f lib/
&& mvn verify -f rest/
&& lib/deployment/release.sh -ik -p lib/ -m "lib/taskana-core/ lib/taskana-spring/ lib/taskana-cdi/"
&& lib/deployment/release.sh -m web/
&& lib/deployment/release.sh -pp -p rest/ -m rest/taskana-rest-spring -mf manifest.yml -swarm lib/taskana-cdi/src/test/java/pro/taskana/TaskanaProducersTest.java
deploy:
provider: cloudfoundry
username: tobias.schaefer@novatec-gmbh.de
password:
secure: dQh3e8Zhi2ucd5NcxHZ337Ku2SFrt0qA8lghtExQU5bcdFziqYKJsVFdD19hNQE6DOZT8FV9OHTB3odZSvV7aa38sq4KDwzJVVitIyU3eNZP0S5AqAv0eKitqQhjY7rnjBIkgMQ2rGTZlAL9g/CQWPlB4rnUPLXv/7+pZP29M3OPK0hyIPw9I0FfU02cM+R2z8SYPRr4MYYbdsTdJeJz+1sKWwQiD4bDE/Kmcs7BALTZ3/HFmu2Kjxk7soERSpXlMvKDkHHJCJMSjQI6zT5Ja6yg4SgOgccLZKuaPwF+8a7RKPOtW+H74zzO/IE9FGimlRKFGHhoFmQh0oI1sMkhRyIH0n/rkCVzI6B8XjDBEdaRjfHZbAkrjapuvhLwSxyklut3CknbSxfgAo8tZefsGVETD1rYkfLA207bkxt6Wk+X1d2pCRFkUoeTjcB+IkqvftTJvTX5vyt927w0pyx/xg9gxBLA3bqzhRL7rwgXgqgrxNUDFT3nxExecPpdEinyVf+jQxmrb1uw1WEFM+dLjA3tByxMEy7PfnfqTvUs8dvs4em1Vln+N5K1+OqU93ze3FmPMmqY3/4r63qdVACtCqHlfGC3HQPUi6fWmBzVNhZ9rF6FJvkECTkvLklnOB9MIoneGk2v46slveUsxKSz985A2aMkYNO+p1VozS8rAfg=
api: https://api.ng.bluemix.net
organization: '"NovaTec Consulting GmbH"'
space: Taskana
on:
repo: Taskana/taskana
all_branches: true
condition: $TRAVIS_TAG =~ ^v[0-9]+\.[0-9]+\.[0-9]+$
- nvm install $NODE_VERSION
&& ci/change_version.sh -m "lib/ rest/" -swarm lib/taskana-cdi/src/test/java/pro/taskana/TaskanaProducersTest.java
&& ./ci/test.sh $DB
jobs:
include:
- stage: Build
install:
- nvm install $NODE_VERSION
&& (cd web && npm install)
&& ci/change_version.sh -m "lib/ rest/" -swarm lib/taskana-cdi/src/test/java/pro/taskana/TaskanaProducersTest.java
script:
- (cd web && npm run build:prod)
&& mvn clean install -q -f lib -DskipTests -Dmaven.javadoc.skip=true
&& mvn clean install -q -f rest -DskipTests -Dmaven.javadoc.skip=true
- stage: "Release / Deploy"
script:
- ci/change_version.sh -i -m "lib/ rest/" -swarm lib/taskana-cdi/src/test/java/pro/taskana/TaskanaProducersTest.java
&& ci/copy-rest-spring.sh $TRAVIS_TAG
&& ci/commitPoms.sh lib/taskana-cdi/src/test/java/pro/taskana/TaskanaProducersTest.java
deploy:
provider: cloudfoundry
username: tobias.schaefer@novatec-gmbh.de
password:
secure: dQh3e8Zhi2ucd5NcxHZ337Ku2SFrt0qA8lghtExQU5bcdFziqYKJsVFdD19hNQE6DOZT8FV9OHTB3odZSvV7aa38sq4KDwzJVVitIyU3eNZP0S5AqAv0eKitqQhjY7rnjBIkgMQ2rGTZlAL9g/CQWPlB4rnUPLXv/7+pZP29M3OPK0hyIPw9I0FfU02cM+R2z8SYPRr4MYYbdsTdJeJz+1sKWwQiD4bDE/Kmcs7BALTZ3/HFmu2Kjxk7soERSpXlMvKDkHHJCJMSjQI6zT5Ja6yg4SgOgccLZKuaPwF+8a7RKPOtW+H74zzO/IE9FGimlRKFGHhoFmQh0oI1sMkhRyIH0n/rkCVzI6B8XjDBEdaRjfHZbAkrjapuvhLwSxyklut3CknbSxfgAo8tZefsGVETD1rYkfLA207bkxt6Wk+X1d2pCRFkUoeTjcB+IkqvftTJvTX5vyt927w0pyx/xg9gxBLA3bqzhRL7rwgXgqgrxNUDFT3nxExecPpdEinyVf+jQxmrb1uw1WEFM+dLjA3tByxMEy7PfnfqTvUs8dvs4em1Vln+N5K1+OqU93ze3FmPMmqY3/4r63qdVACtCqHlfGC3HQPUi6fWmBzVNhZ9rF6FJvkECTkvLklnOB9MIoneGk2v46slveUsxKSz985A2aMkYNO+p1VozS8rAfg=
api: https://api.ng.bluemix.net
organization: '"NovaTec Consulting GmbH"'
space: Taskana
on:
all_branches: true
if: tag =~ ^v[0-9]+\.[0-9]+\.[0-9]+$
- stage: "Release / Deploy"
script:
- ci/release.sh lib/taskana-core $TRAVIS_TAG
&& ci/release.sh lib/taskana-spring $TRAVIS_TAG
&& ci/release.sh lib/taskana-cdi $TRAVIS_TAG
&& ci/release.sh web/ $TRAVIS_TAG
&& ci/release.sh rest/taskana-rest-spring $TRAVIS_TAG
if: (tag =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ OR branch = master) AND type != pull_request

View File

@ -6,11 +6,16 @@ set -e #fail fast
#H
#H prints this help and exits
#H
#H change_version.sh [modules...]
#H change_version.sh <-m modules...> [-i]
#H
#H if a release version exists (extracted from TRAVIS_TAG)
#H the maven versions of all modules will be changed to the given release version.
#H
#H module:
#H directory of a maven project
#H i:
#H increments version
#H
#H Environment variables:
#H - TRAVIS_TAG
#H if this is a tagged build then TRAVIS_TAG contains the version number.
@ -22,21 +27,37 @@ function helpAndExit {
exit "$1"
}
# takes a version (without leading v) and increments its
# last number by one.
# Arguments:
# $1: version (without leading v) which will be patched
# Return:
# version with last number incremented
function increment_version() {
if [[ ! "$1" =~ [0-9]+\.[0-9]+\.[0-9]+ ]]; then
echo "'$1' does not match tag pattern." >&2
exit 1;
fi
echo "${1%\.*}.`expr ${1##*\.*\.} + 1`"
}
# changing version in pom and all its children
# Arguments:
# $1: directory of pom
# $2: new version
function change_version {
mvn org.codehaus.mojo:versions-maven-plugin:2.5:set -f "$1" -DnewVersion="$2" -DartifactId=* -DgroupId=*
mvn versions:set -f "$1" -DnewVersion="$2" -DartifactId=* -DgroupId=* versions:commit
}
function main {
if [[ $# -eq 0 || "$1" == "-h" || "$1" == "--help" ]]; then
helpAndExit 0
fi
[[ $# -eq 0 || "$1" == '-h' || "$1" == '--help' ]] && helpAndExit 0
while [[ $# -gt 0 ]]; do
case $1 in
-i)
INCREMENT="true"
shift # past argument
;;
-m|--modules)
if [[ -z "$2" || "$2" == -* ]]; then
echo "missing parameter for argument '-m|--modules'" >&2
@ -68,12 +89,13 @@ function main {
fi
if [[ "$TRAVIS_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
version=`[[ -n "$INCREMENT" ]] && echo $(increment_version "${TRAVIS_TAG##v}")-SNAPSHOT || echo "${TRAVIS_TAG##v}"`
for dir in ${MODULES[@]}; do
change_version "$dir" "${TRAVIS_TAG##v}"
change_version "$dir" "$version"
done
if [[ -n "$SWARM" ]]; then
sed -i "s/pro.taskana:taskana-core.*-SNAPSHOT/pro.taskana:taskana-core:${TRAVIS_TAG##v}/" "$SWARM"
sed -i "s/pro.taskana:taskana-core.*-SNAPSHOT/pro.taskana:taskana-core:$version/" "$SWARM"
fi
else
echo "skipped version change because this is not a release build"

79
ci/commitPoms.sh Executable file
View File

@ -0,0 +1,79 @@
#!/bin/bash
set -e # fail fast
#H Usage:
#H commitPoms.sh -h | commitPoms.sh --help
#H
#H prints this help and exits
#H
#H commitPoms.sh [additional files...]
#H
#H commits and pushes all *.pom files (+ additional files)
#H
#H Requirements:
#H current commit is a HEAD commit
#H GH_TOKEN - github access token
#H GH_USER - username for the github access token
#H TRAVIS_TAG (format v[0-9]+\.[0-9]+\.[0-9]+)
#H TRAVIS_REPO_SLUG - repo name (in form: owner_name/repo_name)
# Arguments:
# $1: exit code
function helpAndExit {
cat "$0" | grep "^#H" | cut -c4-
exit "$1"
}
# takes a version (without leading v) and increments its
# last number by one.
# Arguments:
# $1: version (without leading v) which will be patched
# Return:
# version with last number incremented
function increment_version() {
if [[ ! "$1" =~ [0-9]+\.[0-9]+\.[0-9]+ ]]; then
echo "'$1' does not match tag pattern." >&2
exit 1;
fi
echo "${1%\.*}.`expr ${1##*\.*\.} + 1`"
}
function main {
[[ "$1" == '-h' || "$1" == '--help' ]] && helpAndExit 0
[[ -z "$GH_USER" || -z "$GH_TOKEN" || -z "$TRAVIS_REPO_SLUG" ]] && helpAndExit 1
if [[ "$TRAVIS_TAG" =~ v[0-9]+\.[0-9]+\.[0-9]+ ]]; then
#check if tagged commit is a head commit of any branch
commit=`git ls-remote -q -t origin | grep "$TRAVIS_TAG" | cut -c1-40`
branch=`git ls-remote -q -h origin | grep "$commit" | sed "s/$commit.*refs\/heads\///"`
if [[ -z "$commit" || -z "$branch" ]]; then
echo "the commit '$commit' of tag '$TRAVIS_TAG' is not a head commit. Can not release" >&2
exit 1
fi
if [[ `echo "$branch" | wc -l` != '1' ]]; then
echo "can not match commit '$commit' to a unique branch." >&2
echo "Please make sure, that the tag '$TRAVIS_TAG' is the head of a unique branch" >&2
echo "Branches detected: $branch"
exit 1
fi
#commit all poms
git checkout -b "$branch"
#to compensate new updates
git pull
git add "./*pom.xml"
for file in "$@"; do
[[ -n "$file" ]] && git add "$file"
done
git commit -m "Updated poms to version `increment_version ${TRAVIS_TAG##v}`-SNAPSHOT"
#push poms (authentication via GH_TOKEN)
git remote add deployment "https://$GH_USER:$GH_TOKEN@github.com/$TRAVIS_REPO_SLUG.git"
git push --quiet --set-upstream deployment "$branch"
else
echo "Nothing to push - this is not a release!"
fi
}
main "$@"

9
ci/copy-rest-spring.sh Executable file
View File

@ -0,0 +1,9 @@
#!/bin/bash
set -e # fail fast
if [[ ! "$1" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "missing tag" >&2
exit 1
fi
cp ~/.m2/repository/pro/taskana/taskana-rest-spring-example/${1##v}/taskana-rest-spring-example-${1##v}.jar taskana-rest-spring-example.jar

79
ci/prepare_db.sh Executable file
View File

@ -0,0 +1,79 @@
#!/bin/bash
set -e #fail fast
#H Usage:
#H prepare_db.sh -h | prepare_db.sh --help
#H
#H prints this help and exits
#H
#H prepare_db.sh <database>
#H
#H downloads and starts docker image for taskana unit tests
#H
#H database:
#H - H2
#H - DB2_10_5
#H - DB2_11_1
#H - POSTGRES
# Arguments:
# $1: exit code
function helpAndExit {
cat "$0" | grep "^#H" | cut -c4-
exit "$1"
}
function main {
[[ $# -eq 0 || "$1" == '-h' || "$1" == '--help' ]] && helpAndExit 0
propFile="$HOME/taskanaUnitTest.properties"
case "$1" in
H2)
;;
DB2_10_5)
if [[ -z `docker ps -aq -f name=^/taskana-db2_10_5$ -f status=running` ]]; then
if [[ -z `docker ps -aq -f name=^/taskana-db2_10_5$` ]]; then
docker run -d -p 49999:50000 --name taskana-db2_10_5 mustaphazorgati/db2:10.5 -d
else
docker start taskana-db2_10_5
fi
fi
echo 'jdbcDriver=com.ibm.db2.jcc.DB2Driver' > $propFile
echo 'jdbcUrl=jdbc:db2://localhost:49999/tskdb' >> $propFile
echo 'dbUserName=db2inst1' >> $propFile
echo 'dbPassword=db2inst1-pwd' >> $propFile
;;
DB2_11_1)
if [[ -z `docker ps -aq -f name=^/taskana-db2_11_1$ -f status=running` ]]; then
if [[ -z `docker ps -aq -f name=^/taskana-db2_11_1$` ]]; then
docker run -d -p 50000:50000 --name taskana-db2_11_1 mustaphazorgati/db2:11.1 -d
else
docker start taskana-db2_11_1
fi
fi
echo 'jdbcDriver=com.ibm.db2.jcc.DB2Driver' > $propFile
echo 'jdbcUrl=jdbc:db2://localhost:50000/tskdb' >> $propFile
echo 'dbUserName=db2inst1' >> $propFile
echo 'dbPassword=db2inst1-pwd' >> $propFile
;;
POSTGRES)
if [[ -z `docker ps -aq -f name=^/taskana-postgres$ -f status=running` ]]; then
if [[ -z `docker ps -aq -f name=^/taskana-postgres$` ]]; then
docker run -d -p 50001:5432 --name taskana-postgres -e POSTGRES_PASSWORD=postgres postgres:10.4
else
docker start taskana-postgres
fi
fi
echo 'jdbcDriver=org.postgresql.Driver' > $propFile
echo 'jdbcUrl=jdbc:postgresql://localhost:50001/postgres' >> $propFile
echo 'dbUserName=postgres' >> $propFile
echo 'dbPassword=postgres' >> $propFile
;;
*)
echo "unknown database '$1'" >&2
exit 1
esac
docker ps
}
main "$@"

78
ci/release.sh Executable file
View File

@ -0,0 +1,78 @@
#!/bin/bash
set -e # fail fast
#H Usage:
#H release.sh -h | release.sh --help
#H
#H prints this help and exits
#H
#H release.sh <module> [version]
#H
#H an easy deployment tool to deploy maven projects.
#H
#H module:
#H
#H path to maven project
#H
#H version:
#H
#H new version for the <module>.
#H format: ^v[0-9]+\.[0-9]+\.[0-9]+$
#H if the format is wrong it will be ignored.
#H
#H requirements:
#H
#H - <module>'s pom file contains the profiles 'release' and 'snapshot'
#H - the files
#H * mvnsettings.xml
#H * codesigning.asc.enc
#H have to exist in the same folder as this script
#H - the environment variables
#H * encrypted_57343c8b243e_key
#H * encrypted_57343c8b243e_iv
#H have to exist (in order to decode codesigning.asc.enc)
# Arguments:
# $1: exit code
function helpAndExit {
cat "$0" | grep "^#H" | cut -c4-
exit "$1"
}
# decripting gpg keys and importing them (needed to sign artifacts)
# Global:
# $encrypted_57343c8b243e_key: decription key
# $encrypted_57343c8b243e_iv: initialisation vector
# Arguments:
# $1: basedir
function decodeAndImportKeys {
if [[ ! -f "$1/codesigning.asc" ]]; then
openssl aes-256-cbc -K "$encrypted_57343c8b243e_key" -iv "$encrypted_57343c8b243e_iv" -in "$1/codesigning.asc.enc" -out "$1/codesigning.asc" -d
gpg --import "$1/codesigning.asc"
fi
}
# deploying a given project
# Arguments:
# $1: project folder (dir)
# $2: profile name
# $3: settings file (dir)
function release {
mvn deploy -f "$1" -P "$2" --settings "$3" -DskipTests=true -B -U
}
# changing version in pom and all its children
# Arguments:
# $1: directory of pom
# $2: new version
function change_version {
mvn versions:set -f "$1" -DnewVersion="$2" -DartifactId=* -DgroupId=* versions:commit
}
function main {
[[ $# -eq 0 || "$1" == '-h' || "$1" == '--help' ]] && helpAndExit 0
[[ "$2" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] && change_version "$1" "${2##v}"
decodeAndImportKeys `dirname "$0"`
release "$1" `[[ "$2" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] && echo "release" || echo "snapshot"` "`dirname "$0"`/mvnsettings.xml"
}
main "$@"

37
ci/test.sh Executable file
View File

@ -0,0 +1,37 @@
#!/bin/bash
set -e # fail fast
#H Usage:
#H test.sh -h | test.sh --help
#H
#H prints this help and exits
#H
#H test.sh <database>
#H
#H tests the taskana application
#H
#H database:
#H - H2
#H - DB2_10_5
#H - DB2_11_1
# Arguments:
# $1: exit code
function helpAndExit {
cat "$0" | grep "^#H" | cut -c4-
exit "$1"
}
function main {
[[ $# -eq 0 || "$1" == '-h' || "$1" == '--help' ]] && helpAndExit 0
REL=`dirname "$0"`
eval "$REL/prepare_db.sh '$1'"
if [[ "$1" == "H2" ]]; then
(cd $REL/../web && npm run test)
mvn clean verify -q -f $REL/../lib/ -B
mvn clean install -q -f $REL/../rest/ -B
else
mvn clean verify -q -f $REL/../lib/taskana-core -B
fi
}
main "$@"

View File

@ -1,327 +0,0 @@
#!/bin/bash
set -e #fail fast
reqRepo="Taskana/taskana"
if [[ -z "$MANIFEST_PREFIX" ]]; then
MANIFEST_PREFIX="target/taskana-rest-spring-example"
fi
#H Usage:
#H release.sh -h | release.sh --help
#H
#H prints this help and exits
#H
#H release.sh [PARAM...]
#H
#H an easy deployment tool to deploy maven projects.
#H
#H On a tagged commit
#H version will be set to the one in the tag
#H maven deploy with the profile 'release' will be excecuted
#H On a non-tagged commit on the master branch
#H maven deploy with the profile 'snapshot' will be excecuted
#H
#H
#H PARAM can be one of the following:
#H -avc | --append-version-change
#H List of modules (path) whose version will be updated after deployment.
#H -d | --dry-run
#H Echos out all commands instead of executing them.
#H -m | --modules
#H List of modules (path) which will be deployed.
#H -mf | --manifest
#H If a manifest file exists the version of an artifact will be replaced.
#H You can Overwrite it by setting the env variable MANIFEST_PREFIX to the required prefix.
#H -p | --parent
#H If a parent pom exists the version change will be done in the parent instead of every module.
#H -ik | --import-keys
#H Toggles import of gpg keys.
#H -pp | --push-poms
#H Toggles the commit & push of new poms (on release build)
#H
#H
#H IMPORTANT:
#H - All Lists have to be passed as one parameter.
#H - When a parameter is duplicated its last occurance will count
#H
#H Environment variables:
#H - encrypted_57343c8b243e_key
#H private key needed for decoding 'codesigning.asc.enc' file in script directory
#H - encrypted_57343c8b243e_iv
#H initialisation vektor to decode 'codesigning.asc.enc' file in scirpt directory
#H - GH_TOKEN
#H token to write back to the git repo after release deployment
#H - MANIFEST_PREFIX
#H if a manifest file is set the pattern matching can be modified.
#H The pattern will then replace '$MANIFEST_PREFIX.*\.jar' with '$MANIFEST_PREFIX-$VERSION-SNAPSHOT.jar'.
#H Default value is '/rest'
#H - TRAVIS_REPO_SLUG
#H git repo slug
#H - TRAVIS_PULL_REQUEST
#H 'false' if this is not a PR build. Otherwise this is a PR build.
#H - TRAVIS_TAG
#H if this is a tagged build then TRAVIS_TAG contains the version number.
#H pattern: v[DIGIT].[DIGIT].[DIGIT]
#H - TRAVIS_BRANCH
#H branch of this build (only used if TRAVIS_TAG is not set)
# Arguments:
# $1: exitcode
function helpAndExit {
cat "$0" | grep "^#H" | cut -c4-
exit "$1"
}
# decripting gpg keys and importing them (needed to sign artifacts)
# Global:
# $encrypted_57343c8b243e_key: decription key
# $encrypted_57343c8b243e_iv: initialisation vector
# Arguments:
# $1: basedir
function decodeAndImportKeys {
$debug openssl aes-256-cbc -K "$encrypted_57343c8b243e_key" -iv "$encrypted_57343c8b243e_iv" -in "$1/codesigning.asc.enc" -out "$1/codesigning.asc" -d
$debug gpg --import "$1/codesigning.asc"
}
# deploying a given project
# Arguments:
# $1: project folder (dir)
# $2: profile name
# $3: settings file (dir)
function deploy {
$debug mvn deploy -f "$1" -P "$2" --settings "$3" -DskipTests=true -B -U
}
# takes a version (without leading v) and increments its
# last number by one.
# Arguments:
# $1: version (without leading v) which will be patched
# Return:
# version with last number incremented
function increment_version() {
if [[ ! "$1" =~ [0-9]+\.[0-9]+\.[0-9]+ ]]; then
echo "'$1' does not match tag pattern." >&2
exit 1;
fi
echo "${1%\.*}.`expr ${1##*\.*\.} + 1`"
}
# changing version in pom and all its children
# Arguments:
# $1: directory of pom
# $2: new version
function change_version {
$debug mvn org.codehaus.mojo:versions-maven-plugin:2.5:set -f "$1" -DnewVersion="$2" -DartifactId=* -DgroupId=*
}
# adds all pom(s) to a git commit and pushes back to the github
# Global:
# $branch: branch where commit will land
# $GH_TOKEN: github token (to authenticate)
# Arguments:
# Additional files which will be committed aswell
function push_new_poms() {
#commit all poms
$debug git checkout -b "$branch"
#to compensate new updates
$debug git pull
$debug git add "./*pom.xml"
for file in "$@"; do
[[ -n "$file" ]] && $debug git add "$file"
done
$debug git commit -m "Updated poms to version `increment_version ${TRAVIS_TAG##v}`-SNAPSHOT"
#push poms (authentication via GH_TOKEN)
$debug git remote add deployment "https://$GH_TOKEN@github.com/$reqRepo.git"
$debug git push --quiet --set-upstream deployment "$branch"
}
# prints all relevant environment methods
# Global:
# -> see help
function print_environment() {
echo "####################################"
echo "dry-run detected."
echo "environment:"
echo " GH_TOKEN: '$GH_TOKEN'"
echo " MANIFEST_PREFIX: '$MANIFEST_PREFIX'"
echo " TRAVIS_BRANCH: '$TRAVIS_BRANCH'"
echo " TRAVIS_TAG: '$TRAVIS_TAG'"
echo " TRAVIS_PULL_REQUEST: '$TRAVIS_PULL_REQUEST'"
echo " TRAVIS_REPO_SLUG: '$TRAVIS_REPO_SLUG'"
echo "####################################"
}
function main {
if [[ $# -eq 0 ]]; then
helpAndExit 0
fi
while [[ $# -gt 0 ]]; do
case $1 in
-avc|--additional-version-change)
if [[ -z "$2" || "$2" == -* ]]; then
echo "missing parameter for argument '-avc|--additional-version-change'" >&2
exit 1
fi
ADDITIONAL_VC=($2)
shift # past argument
shift # past value
;;
-d|--dry-run)
DRY_RUN=YES
shift # past argument
;;
-h|--help)
helpAndExit 0
;;
-m|--modules)
if [[ -z "$2" || "$2" == -* ]]; then
echo "missing parameter for argument '-m|--modules'" >&2
exit 1
fi
MODULES=($2)
shift # past argument
shift # past value
;;
-mf|--manifest)
if [[ -z "$2" || "$2" == -* ]]; then
echo "missing parameter for argument '-mf|--manifest'" >&2
exit 1
fi
MANIFEST="$2"
shift # past argument
shift # past value
;;
-p|--parent)
if [[ -z "$2" || "$2" == -* ]]; then
echo "missing parameter for argument '-p|--parent'" >&2
exit 1
fi
PARENT_DIR="$2"
shift # past argument
shift # past value
;;
-pp|--push-poms)
PUSH_POMS="YES"
shift # past argument
;;
-ik|--import-keys)
IMPORT_KEYS="YES"
shift # past argument
;;
-swarm)
SWARM="$2"
shift # past argument
shift # past value
;;
*) # unknown option
echo "unknown parameter $1" >&2
exit 1
;;
esac
done
if [[ ${#MODULES[@]} -eq 0 ]]; then
echo "Can not perform deployment without any modules" >&2
helpAndExit 1
fi
debug=
if [[ -n "$DRY_RUN" ]]; then
debug=echo
print_environment
fi
if [[ "$TRAVIS_REPO_SLUG" != "$reqRepo" ]]; then
echo "Skipping release to sonatype because this repo's name does not match with: $reqRepo"
exit 0
fi
if [[ "$TRAVIS_PULL_REQUEST" != 'false' ]]; then
echo "Skipping release to sonatype because this is a PR build"
exit 0
fi
if [[ -z "$debug" && (-z "$encrypted_57343c8b243e_key" || -z "$encrypted_57343c8b243e_iv") ]]; then
echo "you are not travis or travis does not have the correct encryption key and iv" >&2
exit 1
fi
if [[ "$TRAVIS_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
profile="release"
if [[ -z "$debug" ]]; then
#check if tagged commit is a head commit of any branch
commit=`git ls-remote -q -t origin | grep "$TRAVIS_TAG" | cut -c1-40`
branch=`git ls-remote -q -h origin | grep "$commit" | sed "s/$commit.*refs\/heads\///"`
if [[ -z "$commit" || -z "$branch" ]]; then
echo "the commit '$commit' of tag '$TRAVIS_TAG' is not a head commit. Can not release" >&2
exit 1
fi
if [[ `echo "$branch" | wc -l` != '1' ]]; then
echo "can not match commit '$commit' to a unique branch." >&2
echo "Please make sure, that the tag '$TRAVIS_TAG' is the head of a unique branch" >&2
echo "Branches detected: $branch"
exit 1
fi
else
#dummy value for dry run
branch="BRANCH"
echo "!!! - Skipping automatic detection of tag branch. Instead using '$branch'"
fi
else
if [[ "$TRAVIS_BRANCH" != 'master' ]]; then
echo "Skipping release to sonatype because this branch is not permitted"
exit 0
fi
profile="snapshot"
fi
if [[ "$IMPORT_KEYS" == 'YES' ]]; then
decodeAndImportKeys `dirname "$0"`
fi
for dir in ${MODULES[@]}; do
deploy "$dir" "$profile" "`dirname "$0"`/mvnsettings.xml"
done
if [[ -n "$branch" ]]; then
if [[ -z "$GH_TOKEN" ]]; then
echo 'GH_TOKEN not set' >&2
exit 1
fi
newVersion=`increment_version ${TRAVIS_TAG##v}`
if [[ -n "$PARENT_DIR" ]]; then
change_version "$PARENT_DIR" "$newVersion-SNAPSHOT"
else
for dir in ${MODULES[@]}; do
change_version "$dir" "$newVersion-SNAPSHOT"
done
fi
for dir in ${ADDITIONAL_VC[@]}; do
change_version "$dir" "$newVersion-SNAPSHOT"
done
if [[ -n "$SWARM" ]]; then
$debug sed -i "s/pro.taskana:taskana-core.*${TRAVIS_TAG##v}/pro.taskana:taskana-core:$newVersion-SNAPSHOT/" "$SWARM"
fi
if [[ -n "$MANIFEST" ]]; then
$debug sed -i "s|$MANIFEST_PREFIX.*\.jar|$MANIFEST_PREFIX-${TRAVIS_TAG##v}.jar|" "$MANIFEST"
fi
if [[ "$PUSH_POMS" == 'YES' ]]; then
push_new_poms "$MANIFEST" "$SWARM"
fi
fi
}
main "$@"

View File

@ -1,12 +1,7 @@
# Configuration file for Cloud Foundry, see https://docs.cloudfoundry.org/devguide/deploy-apps/manifest.html
applications:
- name: taskana-rest
path: rest/taskana-rest-spring-example/target/taskana-rest-spring-example-0.9.2.jar
path: taskana-rest-spring-example.jar
buildpack: https://github.com/cloudfoundry/java-buildpack.git#v3.10
memory: 512M
disk_quota: 256M
- name: taskana-web
path: web/dist
buildpack: https://github.com/cloudfoundry/staticfile-buildpack.git#v1.3.16
memory: 16M
disk_quota: 64M