From 162e11ae1e3e096b4585d191b71ea8617eea30d9 Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Mon, 25 Oct 2021 14:01:29 +0200 Subject: [PATCH] copr-be: slight copr-ping submit script update --- .../backend/templates/copr-ping-script.sh.j2 | 37 +++++++++++++++---- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/roles/copr/backend/templates/copr-ping-script.sh.j2 b/roles/copr/backend/templates/copr-ping-script.sh.j2 index d567c0ecec..05de1d558b 100644 --- a/roles/copr/backend/templates/copr-ping-script.sh.j2 +++ b/roles/copr/backend/templates/copr-ping-script.sh.j2 @@ -1,11 +1,32 @@ #! /bin/sh -start_time=$(date +%s) -output=$(copr build @copr/copr-ping https://pagure.io/copr/copr-test-sources/raw/master/f/buildtag-0-0.src.rpm) -exit_status=$? -stop_time=$(date +%s) -build_id=$(echo "$output" | grep 'Created builds:' | cut -d' ' -f3) -took=$(( stop_time - start_time )) +source_rpm_url=https://pagure.io/copr/copr-test-sources/raw/master/f/buildtag-0-0.src.rpm + +log() +{ + stop_time=$(date +%s) + took=$(( stop_time - start_time )) + echo "build_id=$build_id start=$start_time stop=$stop_time took=$took exit_status=$exit_status" \ + >> "{{ ping_log }}" +} + +start_time=$(date +%s) +output=$(copr build --nowait @copr/copr-ping "$source_rpm_url") +build_id=$(echo "$output" | grep 'Created builds:' | cut -d' ' -f3) +exit_status=$? +if ! expr "$build_id" : '\([0-9]*\)$'; then + # we don't even have the build_id + build_id=unknown +fi + +if test $exit_status -ne 0; then + log +fi + +copr watch-build "$build_id" +exit_status=$? +log + + + -echo "build_id=$build_id start=$start_time stop=$stop_time took=$took exit_status=$exit_status" \ - >> "{{ ping_log }}"