From 59fdf0210697123a52290d64cb53a57c39610014 Mon Sep 17 00:00:00 2001 From: Flibio Date: Sun, 31 Jul 2016 14:34:33 -0600 Subject: [PATCH] Add Continuum CI --- .travis.yml | 11 +++++++++++ build.gradle | 2 +- continuum.sh | 42 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 .travis.yml create mode 100644 continuum.sh diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..9e3af5a --- /dev/null +++ b/.travis.yml @@ -0,0 +1,11 @@ +language: java +jdk: +- oraclejdk8 +notifications: + email: false +install: +- 'chmod +x ./gradlew' +script: gradle shadowJar +after_success: +- 'chmod +x ./continuum.sh' +- './continuum.sh' diff --git a/build.gradle b/build.gradle index 1c6dadf..05f575b 100644 --- a/build.gradle +++ b/build.gradle @@ -12,7 +12,7 @@ targetCompatibility = '1.8' group 'io.github.flibio' -defaultTasks 'licenseFormat', 'clean', 'build' +defaultTasks 'licenseFormat', 'shadowJar' repositories { mavenCentral() diff --git a/continuum.sh b/continuum.sh new file mode 100644 index 0000000..ae8d4de --- /dev/null +++ b/continuum.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash + +# Configuration # +TARGET="http://continuum.flibio.net/api/" +PROJECT="EconomyLite" +BRANCH="develop" +UPLOAD="${TRAVIS_BUILD_DIR}/build/libs/*.jar" + +# Make sure the branch is correct # + +if [[ "${TRAVIS_BRANCH}" != "${BRANCH}" ]]; then + echo "Incorrect branch, stopping script!" + exit; +fi + +# Install JQ # + +wget http://stedolan.github.io/jq/download/linux64/jq +chmod +x ./jq +sudo cp /usr/bin + +# Create a new Continuum build # +echo $(curl -v -X POST -d "project=${PROJECT}&commit=${TRAVIS_COMMIT}&job=${TRAVIS_BUILD_ID}" -u continuum:${CONTINUUM_TOKEN} "${TARGET}newbuild.php") >> response.json +BUILD=$(jq '.build' response.json | tr -d '"') +STATUS=$(jq '.status' response.json | tr -d '"') + +echo "New build status: ${STATUS}" +echo "New build number: ${BUILD}" + +# Check if the build was created successfully # +if [[ ${BUILD} -gt 0 ]]; then + echo "Created build ${BUILD}!" + + # Upload the files # + for f in $UPLOAD + do + echo "Attempting to add artifact ${f}" + echo $(curl -v -X POST --form "file=@${f};filename=${f}" --form "project=${PROJECT}" --form "build=${BUILD}" -u continuum:${CONTINUUM_TOKEN} "${TARGET}upload.php") + done +else + echo "Failed to create a build!" +fi