diff options
| author | Robin Haberkorn <rhaberkorn@fmsbw.de> | 2026-08-08 13:36:47 +0200 |
|---|---|---|
| committer | Robin Haberkorn <rhaberkorn@fmsbw.de> | 2026-08-08 13:36:47 +0200 |
| commit | 702c4f8dd6222144829fa36b58c64a01cccb99a6 (patch) | |
| tree | a01a68cdb872de40a0edb286b5001f866ef5693c | |
| parent | acef961bebcb14c7e09581415de15256bb2251b3 (diff) | |
| download | snippets-702c4f8dd6222144829fa36b58c64a01cccb99a6.tar.gz | |
* send email when a CI run fails
* ignore .fmsbw/images directories - these will contain container build instructions (Makefiles or Dockerfiles)
| -rwxr-xr-x | ci.sh | 26 |
1 files changed, 20 insertions, 6 deletions
@@ -8,7 +8,7 @@ set -e cd /var/git projects=${1:-`echo *`} -for project in $projects; do +for project in $=projects; do test -d $project || continue cd $project @@ -17,14 +17,23 @@ for project in $projects; do # We use a tag to keep track of this. # You can remove this tag to force a rebuild: # git push origin --delete master-fmsbw-ci + # Explicitly specifying CI jobs on the command line also skips this + # behavior. branch=`git rev-parse --abbrev-ref HEAD` - test "`git rev-parse -q --verify $branch-fmsbw-ci || true`" != "`git rev-parse $branch`" || continue + if [ $# -lt 2 -a "`git rev-parse -q --verify $branch-fmsbw-ci || true`" = "`git rev-parse $branch`" ]; then + cd .. + continue + fi # The runner can leave the website and other build artifacts there: htdocs="/var/www/htdocs/projects/$project" ci_scripts=${2:-`git ls-tree --name-only HEAD .fmsbw/`} - for ci_script in $ci_scripts; do + for ci_script in $=ci_scripts; do + # Ignore `images` directories. + # They contain scripts to build the necessary containers. + test "$ci_script" != .fmsbw/images || continue + # Extract OCI image name by stripping any leading number used for sorting # FIXME: This will cause problems for fully qualified image names. # In practice, you need to prepare images to preinstall stuff anyway, so @@ -46,11 +55,15 @@ for project in $projects; do # NOTE: The operating system should be guessed. set +e podman run -t --rm -v $working_copy:/opt/build -v "$htdocs":/opt/htdocs \ - -w /opt/build -e FMSBW_CI=1 "$ci_image" "$ci_script" 2>&1 >"$ci_log" + -w /opt/build -e FMSBW_CI=1 "$ci_image" "$ci_script" &>"$ci_log" rc=$? set -e if [ "$rc" != 0 ]; then echo "[$project:$branch] CI FAILED. See $ci_log" + swaks --server localhost \ + --from CI@fmsbw.de --to rhaberkorn@fmsbw.de \ + --header "Subject: [$project:$branch] `basename $ci_script` FAILED" \ + --body "@$ci_log" rm -rf $working_copy # The next ci_scripts in the series could depend on build artifacts, # so abort here. @@ -61,8 +74,9 @@ for project in $projects; do done # Update the CI tag. - # But avoid creating it for repos without any CI configured. - test -z "`git ls-tree --name-only HEAD .fmsbw/`" || git tag -f $branch-fmsbw-ci $branch + # But avoid creating it for repos without any CI configured + # or when restricting the run to a selection of jobs via command line argument. + test $# -ge 2 -o -z "$ci_scripts" || git tag -f $branch-fmsbw-ci $branch # Regenerate index.htmls generate-index-html -R "$htdocs/downloads" || true |
