Merge "Nexus retirement CI job clean up"
[ci-management.git] / jjb / scripts / publish_backup_logs.sh
1 #!/bin/bash
2
3 # Copyright (c) 2021 Cisco and/or its affiliates.
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at:
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 echo "---> publish_backup_logs.sh"
17
18 S3_BUCKET="logs.fd.io"
19 CDN_URL="logs.nginx.service.consul"
20 export AWS_ENDPOINT_URL="http://storage.service.consul:9000"
21 PYTHON_SCRIPT="/w/workspace/publish_library.py"
22
23 # FIXME: s3 config (until migrated to config provider, then pwd will be reset)
24 mkdir -p ${HOME}/.aws
25 echo "[default]
26 aws_access_key_id = storage
27 aws_secret_access_key = Storage1234" > "$HOME/.aws/credentials"
28
29 mkdir -p "$WORKSPACE/archives"
30
31 s3_path="$JENKINS_HOSTNAME/$JOB_NAME/$BUILD_NUMBER/"
32
33 echo "INFO: S3 path $s3_path"
34
35 echo "INFO: archiving backup logs to S3"
36 python3 $PYTHON_SCRIPT deploy_s3 "$S3_BUCKET" "$s3_path" \
37     "$BUILD_URL" "$WORKSPACE"
38
39 echo "S3 build backup logs: <a href=\"https://$CDN_URL/$s3_path\">https://$CDN_URL/$s3_path</a>"