From 7ee8a94965b627caf7b8b68e045b8f44b8e9c8e1 Mon Sep 17 00:00:00 2001 From: Douglas Raillard Date: Fri, 14 Jun 2024 13:19:18 +0100 Subject: [PATCH] .gitlab-ci.yml: Fix failed doc build handling --- .gitlab-ci.yml | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 39c875231..275d86895 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -265,14 +265,20 @@ pages: cd ./doc && sphinx-build -b html -n --no-color -W --keep-going -T -j auto -d "$doctree" . "$out/$publish_as" ) } - build_branch main main - build_branch preview preview - build_branch master master - - # If the folder is empty, remove it to avoid emptying the documentation and stop here. - if rmdir "$out" &>/dev/null; then - exit 0 - fi + + function fail() { + if ! "$@"; then + # If one of the build phases failed, make sure we do not + # accidentally deploy a partial artifact (likely mostly empty) + # and exit with error + rm -r "$out" &>/dev/null + exit 1 + fi + } + + fail build_branch main main + fail build_branch preview preview + fail build_branch master master # TODO: For now the release branch doc won't build as it lacks some necessary fixes # build_branch release release -- GitLab