Merge pull request #666 from jcvenegas/obs-detect-build

obs: wait: Fix error to detect building job
This commit is contained in:
Jose Carlos Venegas Munoz
2019-08-06 12:59:37 -05:00
committed by GitHub
2 changed files with 51 additions and 23 deletions

View File

@@ -56,6 +56,7 @@ docker_run() {
--env GO_ARCH="${GO_ARCH}" \
--env PUSH="${PUSH:-}" \
--env DEBUG="${DEBUG:-}" \
--env OBS_PROJECT="${OBS_PROJECT:-}" \
--env OBS_SUBPROJECT="${OBS_SUBPROJECT:-}" \
-v "${cache_dir}":/var/tmp/osbuild-packagecache/ \
-v "${_obs_docker_packaging_repo_dir}":"${_obs_docker_packaging_repo_dir}" \

View File

@@ -11,6 +11,10 @@ set -o errtrace
script_name="$(basename "${BASH_SOURCE[0]}")"
OBS_PROJECT=${OBS_PROJECT:-"home:katacontainers:"}
# Project to wait for
project=""
handle_error() {
local exit_code="${?}"
local line_number="${1:-}"
@@ -31,12 +35,33 @@ run_in_docker() {
fi
}
# Check all project has finshed the build
wait_finish_building() {
while osc pr -q | grep '(building)'; do sleep 5; done
# just in case something goes wrong
while osc pr -q | grep '(building)'; do sleep 5; done
local out
while true; do
sleep 10
out=$(osc api "/build/${project}/_result")
if echo "${out}" | grep '<details>failed</details>'; then
echo "Project ${project} has failed packages"
osc pr
exit 1
fi
if echo "${out}" | grep 'code="blocked"'; then
echo "Project ${project} has blocked packages, waiting"
continue
fi
if echo "${out}" | grep 'code="excluded"'; then
echo "Project ${project} has excluded packages, waiting"
continue
fi
if echo "${out}" | grep 'state="building"'; then
echo "Project ${project} is still building, waiting"
continue
fi
echo "No jobs with building status were found"
echo "${out}"
break
done
}
# obs distro final status is 'published'
@@ -65,8 +90,7 @@ wait_published() {
check_failed() {
failed_query=$(osc pr -c -s F)
regex=".*failed.*"
if [[ ${failed_query} =~ ${regex} ]];then
if [[ ${failed_query} =~ failed ]]; then
echo "ERROR: Build failed"
osc pr -V -s 'F'
exit 1
@@ -106,8 +130,11 @@ main() {
usage "Invalid option: ${1:-}" 1
;;
esac
OBS_SUBPROJECT="${OBS_SUBPROJECT:-releases:x86_64:alpha}"
project="home:katacontainers:${OBS_SUBPROJECT}"
project=${1:-}
if [ "${project}" == "" ]; then
OBS_SUBPROJECT="${OBS_SUBPROJECT:-}"
project="${OBS_PROJECT}${OBS_SUBPROJECT}"
fi
echo "Checkout: ${project}"
osc co "$project" || true
cd "$project" || exit 1