aboutsummaryrefslogtreecommitdiff
path: root/brep/handler/ci/ci.bash.in
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-08-23 22:29:35 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2018-08-28 21:46:41 +0300
commit8a094bb0481a9c53646cc15db2e8acecafc3d10c (patch)
tree4fd7012b6a26eb852d42fba8b52bfcf8f1cf2fdd /brep/handler/ci/ci.bash.in
parent7e0e141273032c7afc1a9129512aa42c672fcf5d (diff)
Add basic support for CI request handling
Diffstat (limited to 'brep/handler/ci/ci.bash.in')
-rw-r--r--brep/handler/ci/ci.bash.in41
1 files changed, 41 insertions, 0 deletions
diff --git a/brep/handler/ci/ci.bash.in b/brep/handler/ci/ci.bash.in
new file mode 100644
index 0000000..023e98e
--- /dev/null
+++ b/brep/handler/ci/ci.bash.in
@@ -0,0 +1,41 @@
+# file : brep/handler/ci/ci.bash.in
+# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd
+# license : MIT; see accompanying LICENSE file
+
+# Utility functions useful for implementing CI request handlers.
+
+if [ "$brep_handler_ci" ]; then
+ return 0
+else
+ brep_handler_ci=true
+fi
+
+@import brep/handler/handler@
+
+# Serialize the CI result manifest to stdout and exit the (sub-)shell with the
+# zero status.
+#
+reference= # Should be assigned by the handler when becomes available.
+
+function exit_with_manifest () # <status> <message>
+{
+ trace_func "$@"
+
+ local sts="$1"
+ local msg="$2"
+
+ manifest_serializer_start
+
+ manifest_serialize "" "1" # Start of manifest.
+ manifest_serialize "status" "$sts"
+ manifest_serialize "message" "$msg"
+
+ if [ -n "$reference" ]; then
+ manifest_serialize "reference" "$reference"
+ elif [ "$sts" == "200" ]; then
+ error "no reference for code $sts"
+ fi
+
+ manifest_serializer_finish
+ run exit 0
+}