Possible to get email notification for build failures?

As the title says, is (would) it be possible to configure some kind of notification when my app fails to build?

It’s somewhat stochastic when the build agent picks up new versions, so I usually manually check 1-2 weeks after I made a new release. Would be nicer to get pinged somehow if the build fails for some reason.

1 Like

F-Droid recently got an API where you can query failed builds: https://f-droid.org/repo/status/build.json

With a command like the one below, you can get details about the failed build (if your app is listed in the file):

curl https://f-droid.org/repo/status/build.json \
    | jq -r '.failedBuilds[] | select(.[0] == "your.package.name")'
1 Like

thanks. I can work with this.

In case anyone else is interested, here are the scripts I’m using to get notification emails.

  • file: /home/USERNAME/bin/fdroidcheck
#!/bin/bash -eu

PKG="com.nononsenseapps.feeder"
EMAIL="alice@example.org"

BF="/tmp/build.json"
BFHSH=""

if [ -f "${BF}" ]; then
  BFHSH="$(sha256sum "${BF}")"
fi

curl --silent --output "${BF}" --time-cond "${BF}" https://f-droid.org/repo/status/build.json

if [[ "${BFHSH}" == "$(sha256sum "${BF}")" ]]; then
  echo >&2 "No new build"
  exit 0
fi

success="$(jq -r ".successfulBuilds[] | select(.id == \"${PKG}\")" "${BF}")"
failure="$(jq -r ".failedBuilds[] | select(.[0] == \"${PKG}\")" "${BF}")"

subject=""
msg=""

if [ -n "${failure}" ]; then
  echo >&2 "Failed build!"
  echo >&2 "$failure"

  versioncode="$(echo "${failure}" | jq -r ".[1]")"
  cause="$(echo "${failure}" | jq -r ".[2]")"

  subject="F-Droid build failure for ${PKG}:${versioncode}"
  msg=$(cat <<EOF
Fdroid recently tried to build ${PKG} with versionCode ${versioncode} but encountered a failure:

${cause}
EOF
)

elif [ -n "${success}" ]; then
  echo >&2 "Successful build!"
  echo >&2 "$success"

  versioncode="$(echo "${success}" | jq -r ".CurrentVersionCode")"
  versionname="$(echo "${success}" | jq -r ".CurrentVersion")"

  subject="F-Droid has successfully built ${PKG}:${versionname}"
  msg=$(cat <<EOF
Fdroid has successfully built ${PKG} with versionCode ${versioncode} and version ${versionname}.
EOF
)

else
  echo >&2 "${PKG} not part of build"
  exit 0
fi

echo >&2 "${msg}"

echo "${msg}" | mail -s "${subject}" "${EMAIL}"
  • file /home/USERNAME/.config/systemd/user/fdroidcheck.service
[Unit]
Description=Fdroid build status checker
After=network-online.target

[Service]
Type=simple
ExecStart=/home/USERNAME/bin/fdroidcheck
  • file /home/USERNAME/.config/systemd/user/fdroidcheck.timer
[Unit]
Description=Fdroid build status checker

[Timer]
OnUnitActiveSec=2min
OnBootSec=5min
# Random delay up to this many secs
RandomizedDelaySec=120

[Install]
WantedBy=timers.target

Enable periodic script running with

systemctl --user daemon-reload
systemctl --user enable --now fdroidcheck.timer
1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.