aboutsummaryrefslogtreecommitdiffstats
path: root/priv/buildkite-pre-artifact-hook
diff options
context:
space:
mode:
Diffstat (limited to 'priv/buildkite-pre-artifact-hook')
-rw-r--r--priv/buildkite-pre-artifact-hook21
1 files changed, 21 insertions, 0 deletions
diff --git a/priv/buildkite-pre-artifact-hook b/priv/buildkite-pre-artifact-hook
new file mode 100644
index 0000000..ff76fdd
--- /dev/null
+++ b/priv/buildkite-pre-artifact-hook
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+source /etc/buildkite-env
+
+LOGS_PATH=logs/$BUILDKITE_PIPELINE_SLUG/$BUILDKITE_BUILD_NUMBER/$BUILDKITE_AGENT_META_DATA_OS/
+ssh buildkite@$BUILDKITE_LOGS_SERVER mkdir -p $LOGS_PATH
+
+# Terminal output.
+curl -H "Authorization: Bearer $BUILDKITE_API_TOKEN" "https://api.buildkite.com/v2/organizations/$BUILDKITE_ORGANIZATION_SLUG/pipelines/$BUILDKITE_PIPELINE_SLUG/builds/$BUILDKITE_BUILD_NUMBER/jobs/$BUILDKITE_JOB_ID/log" -H "Accept: text/plain" -o output.txt
+scp -p output.txt buildkite@$BUILDKITE_LOGS_SERVER:$LOGS_PATH
+rm -f output.txt
+
+# Common Test logs.
+test -d logs/ && \
+ scp -rp logs/* buildkite@$BUILDKITE_LOGS_SERVER:$LOGS_PATH
+
+# Erlang.mk packages.
+test -f test/packages/errors.log && \
+ scp -p test/packages/errors.log buildkite@$BUILDKITE_LOGS_SERVER:$LOGS_PATH
+
+echo "<html><head><meta http-equiv='refresh' content='0;URL=https://builds.ninenines.eu/$LOGS_PATH'/></head></html>" > logs.html