Skip to content

Commit

Permalink
Closes inspectIT#80 - Upload test reports after failures on TravisCI
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusoe committed Jan 22, 2019
1 parent 01b33e0 commit 63ae41a
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 3 deletions.
12 changes: 9 additions & 3 deletions .travis.yml
Expand Up @@ -18,8 +18,11 @@ cache:
- $HOME/ibm-jdk-installer/

install: true
script:
- ./gradlew test systemTest
script: ./gradlew test systemTest

after_failure:
- chmod +x ./resources/upload-test-reports.sh
- ./resources/upload-test-reports.sh

jobs:
include:
Expand All @@ -39,7 +42,10 @@ jobs:
- sudo update-alternatives --set "javac" "$HOME/ibm-jdk-8/bin/javac"
- export JAVA_HOME=$HOME/ibm-jdk-8
- java -version
script: ./gradlew :inspectit-oce-agent:systemTest
script: ./gradlew test systemTest
after_failure:
- chmod +x ./resources/upload-test-reports.sh
- ./resources/upload-test-reports.sh

- stage: deploy
name: "Code Coverage Reporting"
Expand Down
37 changes: 37 additions & 0 deletions resources/upload-test-reports.sh
@@ -0,0 +1,37 @@
#!/bin/bash

# Create test report archive and upload it to transfer.sh

echo "Packing and uploading test-reports"

ARCHIVE_FILE_NAME="inspectit-oce-test-reports-$TRAVIS_JOB_NUMBER.zip"
ARCHIVE_FILE="$TRAVIS_BUILD_DIR/$ARCHIVE_FILE_NAME"

DIRECTORY="$TRAVIS_BUILD_DIR/inspectit-oce-agent/build/reports/tests/"
if [ -d "$DIRECTORY" ]; then
echo "Packing test-reports of agent project.."
cd "$DIRECTORY"
mv ./* agent
zip -q -r "$ARCHIVE_FILE" .
fi

DIRECTORY="$TRAVIS_BUILD_DIR/inspectit-oce-core/build/reports/tests/"
if [ -d "$DIRECTORY" ]; then
echo "Packing test-reports of core project.."
cd "$DIRECTORY"
mv ./* core
zip -q -r "$ARCHIVE_FILE" .
fi

if [ -f "$ARCHIVE_FILE" ]; then
echo "Found test-report archive. Uploading it to 'transfer.sh'."

TRANSFER_SH_URL=$(curl -s --upload-file "$ARCHIVE_FILE" "https://transfer.sh/$ARCHIVE_FILE_NAME")

echo "Archive containing test-reports can be found and downloaded at the following URL:"
echo ""
echo " $TRANSFER_SH_URL"
echo ""
else
echo "Archive containing test-reports does not exist. Nothing to upload."
fi

0 comments on commit 63ae41a

Please sign in to comment.