Add conditional block for s3 90/61890/7
authorHoua Yang <hyang@contractor.linuxfoundation.org>
Tue, 1 Oct 2019 20:06:03 +0000 (15:06 -0500)
committerHoua Yang <hyang@contractor.linuxfoundation.org>
Wed, 5 Feb 2020 21:50:11 +0000 (15:50 -0600)
Add conditional block for log shipping via AWS s3.
This will need some sort of environment variable, so
the build will know to also ship logs to s3.

Issue-Id: RELENG-2379, RELENG-2380
Signed-off-by: Houa Yang <hyang@contractor.linuxfoundation.org>
Change-Id: Iff922d22e3ffafb068ce7053194f8b7d289111b8

shell/logs-deploy.sh

index 44ec180..633aae8 100644 (file)
@@ -14,8 +14,8 @@ echo "---> logs-deploy.sh"
 # Disable 'globbing'
 set -euf -o pipefail
 
-if [[ -z $"${LOGS_SERVER:-}" ]]; then
-    echo "WARNING: Logging server not set"
+if [[ -z ${LOGS_SERVER:-} ]]; then
+    echo "WARNING: Nexus logging server not set"
 else
     nexus_url="${NEXUSPROXY:-$NEXUS_URL}"
     nexus_path="${SILO}/${JENKINS_HOSTNAME}/${JOB_NAME}/${BUILD_NUMBER}"
@@ -40,3 +40,20 @@ else
 
     echo "Build logs: <a href=\"$LOGS_SERVER/$nexus_path\">$LOGS_SERVER/$nexus_path</a>"
 fi
+
+if [[ -z ${S3_BUCKET:-} ]]; then
+    echo "WARNING: S3 logging server not set"
+else
+    s3_path="$SILO/$JENKINS_HOSTNAME/$JOB_NAME/$BUILD_NUMBER"
+    echo "INFO: S3 path $s3_path"
+
+    pattern_opts=()
+    for arg in $ARCHIVE_ARTIFACTS; do
+        pattern_opts+=("-p" "$arg")
+    done
+    lftools deploy s3 "${pattern_opts[@]}" "$S3_BUCKET" "$s3_path" \
+        "$BUILD_URL" "$WORKSPACE"
+
+    echo "Build logs: <a href=\"https://$S3_BUCKET.s3.amazonaws.com/$s3_path\"></a>"
+fi
+