Commit 23fab732 authored by Mehdi Dogguy's avatar Mehdi Dogguy

Add emails_on_push.sh

parent 3eafd89c
...@@ -20,6 +20,11 @@ messages as 'pending' on Debian BTS. ...@@ -20,6 +20,11 @@ messages as 'pending' on Debian BTS.
Sets up a webhook for project 'foo' which closes Debian BTS bugs appearing Sets up a webhook for project 'foo' which closes Debian BTS bugs appearing
in commit messages. in commit messages.
* emails_on_push.sh foo "email addresses"
Sets up email notifications on push for project 'foo'. Emails will be sent
to "mail addresses".
In order to use these scripts, you must create a 'salsarc' file with the In order to use these scripts, you must create a 'salsarc' file with the
following content: following content:
......
#!/bin/sh
set -eu
. ./salsarc
if [ "$#" -ne 2 ] || [ -z "$1" ]; then
echo "Usage: $0 foo [recipient ...]" >&2
echo " where 'foo' is the Salsa project name for which you want to setup email notifications for [recipients]." >&2
echo " If recipients is empty, then this script will use 'dispatch+foo_vcs@tracker.debian.org'" >&2
exit 1
fi
PROJECT_NAME="$1"
RECIPIENTS="$2"
PROJECT_ID=$(curl --silent -f -XGET --header "PRIVATE-TOKEN: $SALSA_TOKEN" $SALSA_URL/v3/projects/owned | jq ".[] | select(.name == \"$PROJECT_NAME\") | .id")
if [ -z "$PROJECT_ID" ]; then
echo "Project $PROJECT_NAME not found among your owned projects on $SALSA_URL service" >&2
exit 1
else
echo "Setting up emails_on_push service for $PROJECT_NAME ($PROJECT_ID)"
fi
if [ -z "$RECIPIENTS" ]; then
RECIPIENTS="dispatch+${PROJECT_NAME}_vcs@tracker.debian.org"
fi
case $PROJECT_ID in
''|*[!0-9]*) echo "$PROJECT_NAME not found using $SALSA_URL service" ;;
*) curl -XPUT --header "PRIVATE-TOKEN: $SALSA_TOKEN" \
$SALSA_URL/v4/projects/$PROJECT_ID/services/emails-on-push \
--data "recipients=$RECIPIENTS";
echo;
if [ $? -eq 0 ]; then
echo "All done."
else
echo "Something went wrong!"
fi;;
esac
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment