Skip to content

Commit

Permalink
Merge pull request #2734 from ncdc/add-download-prow-logs-script
Browse files Browse the repository at this point in the history
馃尡 Add make target to download e2e logs from Prow
  • Loading branch information
openshift-merge-robot committed Feb 2, 2023
2 parents f18044f + a398c33 commit 26d200c
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,10 @@ clean-workdir: WORK_DIR ?= .
clean-workdir:
rm -fr $(WORK_DIR)/.kcp*

.PHONY: download-e2e-logs
download-e2e-logs:
OUT=$(OUT) URL=$(URL) hack/download-e2e-logs.sh

.PHONY: help
help: ## Show this help.
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
46 changes: 46 additions & 0 deletions hack/download-e2e-logs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env bash

# Copyright 2021 The KCP Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -o errexit
set -o nounset
set -o pipefail

if ! command -v gsutil &> /dev/null; then
echo "gsutil missing. Install the gcloud SDK first"
exit 1
fi

EXAMPLE_URL=https://prow.ci.openshift.org/view/gs/origin-ci-test/pr-logs/pull/kcp-dev_kcp/2707/pull-ci-kcp-dev-kcp-main-e2e-sharded/1620846315476881408

if [[ -z "${URL:-}" ]]; then
echo -e "URL is required\n\nExample URL: $EXAMPLE_URL\n"
exit 1
fi

# Strip off the prefix
PR_ISH="${URL#https://prow.ci.openshift.org/view/gs/origin-ci-test/pr-logs/pull/kcp-dev_kcp/}"

# Split into fields
PR="$(echo $PR_ISH | cut -d / -f 1)"
JOB="$(echo $PR_ISH | cut -d / -f 2)"
E2E="$(echo $JOB | grep -o 'e2e.*')"
RUN="$(echo $PR_ISH | cut -d / -f 3)"

# Default to placing logs in prow/$PR/$JOB/$RUN/
OUT=${OUT:-prow/$PR/$JOB/$RUN/}
mkdir -p $OUT

gsutil -m cp -r gs://origin-ci-test/pr-logs/pull/kcp-dev_kcp/$PR/$JOB/$RUN/artifacts/$E2E/$E2E/artifacts/kcp/ $OUT

0 comments on commit 26d200c

Please sign in to comment.