URL: https://github.com/freeipa/freeipa/pull/449
Author: martbab
 Title: #449: Travis CI: Upload the logs from failed jobs to transfer.sh
Action: synchronized

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/449/head:pr449
git checkout pr449
From 1e7f06a1c751a0d2027367769d389c0c24a67762 Mon Sep 17 00:00:00 2001
From: Martin Babinsky <mbabi...@redhat.com>
Date: Wed, 8 Feb 2017 10:38:57 +0100
Subject: [PATCH] Travis CI: Upload the logs from failed jobs to transfer.sh

When a non-lint job fails, all the relevant logs from the test runner
will be gzipped and uploaded to https://transfer.sh file sharing
service. The download link will then be displayed at the very end of the
Travis build log.
---
 .test_runner_config.yaml | 10 ++++++++++
 .travis.yml              | 17 +++++++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/.test_runner_config.yaml b/.test_runner_config.yaml
index dc08d79..e473d49 100644
--- a/.test_runner_config.yaml
+++ b/.test_runner_config.yaml
@@ -31,6 +31,16 @@ steps:
   - dnf builddep -y ${builddep_opts} --spec freeipa.spec.in --best --allowerasing
   cleanup:
   - chown -R ${uid}:${gid} ${container_working_dir}
+  - journalctl -b --no-pager > systemd_journal.log
+  - >
+      tar --ignore-failed-read -cvf ${container_working_dir}/var_log.tar
+      /var/log/dirsrv
+      /var/log/httpd
+      /var/log/ipa*
+      /var/log/krb5kdc.log
+      /var/log/pki
+      systemd_journal.log
+  - chown ${uid}:${gid} ${container_working_dir}/var_log.tar
   configure:
   - ./autogen.sh
   install_packages:
diff --git a/.travis.yml b/.travis.yml
index 6301974..04b766b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -12,6 +12,8 @@ env:
           PEP8_ERROR_LOG="pep8_errors.log"
           CI_RESULTS_LOG="ci_results_${TRAVIS_BRANCH}.log"
           CI_BACKLOG_SIZE=5000
+          CI_RUNNER_LOGS_DIR="/tmp/test-runner-logs"
+          CI_RUNNER_LOG_ARCHIVE="freeipa-ci-pr-${TRAVIS_PULL_REQUEST}-job-${TRAVIS_JOB_NUMBER}.tar.gz"
     matrix:
         - TASK_TO_RUN="lint"
         - TASK_TO_RUN="run-tests"
@@ -31,7 +33,22 @@ install:
       git+https://github.com/freeipa/ipa-docker-test-runner@release-0-2-1
 
 script:
+    - mkdir -p $CI_RUNNER_LOGS_DIR
     - travis_wait 50 ./.travis_run_task.sh
 after_failure:
     - echo "Test runner output:"; tail -n $CI_BACKLOG_SIZE $CI_RESULTS_LOG
     - echo "PEP-8 errors:"; cat $PEP8_ERROR_LOG
+    - >
+      echo "Archiving CI logs";
+      if [[ "$TASK_TO_RUN" != "lint" ]]; then
+          tar --ignore-failed-read -uvf var_log.tar $CI_RESULTS_LOG $PEP8_ERROR_LOG;
+          gzip var_log.tar;
+          mv var_log.tar.gz $CI_RUNNER_LOG_ARCHIVE;
+
+          transfer_url=$(
+            curl --upload-file \
+            ./$CI_RUNNER_LOG_ARCHIVE \
+            https://transfer.sh/${CI_RUNNER_LOG_ARCHIVE}) &&
+            echo "Download log archive from ${transfer_url}" ||
+            echo "Failed to upload log archive!";
+       fi
-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to