+++ /dev/null
-#!/bin/sh
-
-set -e
-set -u
-
-escape() {
- echo "$1" | sed -e 's/@/@@/g'
-}
-
-pocket=$(escape "$1")
-package=$(escape "$2")
-commit=$(escape "$3")
-principal=$(escape "$4")
-
-base=build.hooks.failed_submit.zephyr
-class=$(invirt-getconf "$base.class" 2>/dev/null || :)
-instance=$(invirt-getconf "$base.instance" 2>/dev/null || :)
-zsig=$(invirt-getconf "$base.zsig" 2>/dev/null || :)
-
-if [ -z "$class" ]; then
- echo "I don't know where to send a commit zephyr!" >&2
- echo "Please provide a value for $base.class in" >&2
- echo "your invirt config file." >&2
- exit 1
-fi
-
-(echo "A new job has @{@color(red)failed} to be submitted to the Invirtibuilder:"
- echo
- echo "pocket: $pocket"
- echo "package: $package"
- echo "commit: $commit"k
- echo "principal: $principal"
- echo
- echo -n "Failure: ";
- ( cat | sed -e 's/@/@@/g' ) ) | zwrite -c "$class" -i "${instance:-$commit}" -s "${zsig:-failed-submit}: $pocket" -d
--- /dev/null
+post-build
\ No newline at end of file
(Build %(build_id)s was submitted by %(principal)s at %(inserted_at)s.)""" % values
return msg
+def submit_completion_msg(succeeded, values, verbose=True, success=lambda x: x, failure=lambda x: x):
+ values = dict(values)
+ if succeeded:
+ values['result'] = success(values['result'])
+ else:
+ values['result'] = failure(values['result'])
+ msg = """Submission of %(commit)s to be built in %(pocket)s %(result)s.
+Build submitted by %(principal)s.""" % values
+ return msg
+
+
# Names of hooks
POST_BUILD = 'post-build'
FAILED_BUILD = 'failed-build'
+POST_SUBMIT = 'post-submit'
+FAILED_SUBMIT = 'failed-submit'
# Types of communication
message_generators = {
ZEPHYR : { POST_BUILD : build_completion_msg,
- FAILED_BUILD : build_completion_msg },
+ FAILED_BUILD : build_completion_msg,
+ POST_SUBMIT : submit_completion_msg,
+ FAILED_SUBMIT : submit_completion_msg },
MAIL : { POST_BUILD : build_completion_msg,
- FAILED_BUILD : build_completion_msg }
+ FAILED_BUILD : build_completion_msg,
+ POST_SUBMIT : submit_completion_msg,
+ FAILED_SUBMIT : submit_completion_msg }
}
def zephyr_escape(m):
hook_config = config.build.hooks.post_build
elif prog == FAILED_BUILD:
hook_config = config.build.hooks.failed_build
+ elif prog == POST_SUBMIT:
+ hook_config = config.build.hooks.post_submit
+ elif prog == FAILED_SUBMIT:
+ hook_config = config.build.hooks.failed_submit
else:
parser.error('hook script invoked with unrecognized name %s' % prog)
return 2
assert prog == FAILED_BUILD
values['result'] = 'failed'
succeeded = False
+ elif prog in [POST_SUBMIT, FAILED_SUBMIT]:
+ if len(args) != 4:
+ parser.set_usage('Usage: %prog [options] pocket package commit principal')
+ parser.print_help()
+ return 2
+ values = { 'pocket' : args[0],
+ 'package' : args[1],
+ 'commit' : args[2],
+ 'principal' : args[3],
+ 'default_instance' : 'submission',
+ 'default_subject' : 'Submission %(result)s: %(package)s %(version)s in %(pocket)s'}
+ if prog == POST_SUBMIT:
+ values['result'] = 'succeeded'
+ succeeded = True
+ else:
+ values['result'] = 'failed'
+ succeeded = False
else:
raise AssertionError('Impossible state')
+++ /dev/null
-#!/bin/sh
-
-set -e
-set -u
-
-escape() {
- echo "$1" | sed -e 's/@/@@/g'
-}
-
-pocket=$(escape "$1")
-package=$(escape "$2")
-commit=$(escape "$3")
-principal=$(escape "$4")
-
-base=build.hooks.post_submit.zephyr
-class=$(invirt-getconf "$base.class" 2>/dev/null || :)
-instance=$(invirt-getconf "$base.instance" 2>/dev/null || :)
-zsig=$(invirt-getconf "$base.zsig" 2>/dev/null || :)
-
-if [ -z "$class" ]; then
- echo "I don't know where to send a commit zephyr!" >&2
- echo "Please provide a value for $base.class in" >&2
- echo "your invirt config file." >&2
- exit 1
-fi
-
-(echo "A new job has been submitted to the Invirtibuilder:";
- echo;
- echo "pocket: $pocket";
- echo "package: $package";
- echo "commit: $commit";
- echo "principal: $principal") | zwrite -c "$class" -i "${instance:-$commit}" -s "${zsig:-Git}: $pocket" -d
--- /dev/null
+post-build
\ No newline at end of file
+++ /dev/null
-#!/bin/sh
-
-set -e
-set -u
-
-escape() {
- echo "$1" | sed -e 's/@/@@/g'
-}
-
-build_id=$(escape "$1")
-pocket=$(escape "$2")
-package=$(escape "$3")
-commit=$(escape "$4")
-principal=$(escape "$5")
-version=$(escape "$6")
-inserted_at=$(escape "$7")
-
-base=build.hooks.pre_build.zephyr
-class=$(invirt-getconf "$base.class" 2>/dev/null || :)
-instance=$(invirt-getconf "$base.instance" 2>/dev/null || :)
-zsig=$(invirt-getconf "$base.zsig" 2>/dev/null || :)
-
-if [ -z "$class" ]; then
- echo "I don't know where to send a commit zephyr!" >&2
- echo "Please provide a value for $base.class in" >&2
- echo "your invirt config file." >&2
- exit 1
-fi
-
-(echo "About to begin an Invirtibuild of $package v$version in $pocket."
- echo "from commit $commit.";
- echo
- echo "(Build $build_id was submitted by $principal at $inserted_at.)") | zwrite -c "$class" -i "${instance:-build_$build_id}" -s "${zsig:-pre-build}: $pocket" -d
--- /dev/null
+post-build
\ No newline at end of file