Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
hooks: Switch to passing values through the environment.
Alex Vandiverecfb12404a8f
diff --git a/puppet/zulip/files/hooks/post-deploy.d/sentry.hook b/puppet/zulip/files/hooks/post-deploy.d/sentry.hookindex 19215e7c476..c57e1eb8b08 100755--- a/puppet/zulip/files/hooks/post-deploy.d/sentry.hook+++ b/puppet/zulip/files/hooks/post-deploy.d/sentry.hook@@ -1,6 +1,4 @@#!/usr/bin/env bash-# Arguments: OLD_COMMIT NEW_COMMIT ...where both are `git describe`-# output or tag names. The CWD will be the new deploy directory.set -eset -udiff --git a/puppet/zulip/files/hooks/pre-deploy.d/sentry.hook b/puppet/zulip/files/hooks/pre-deploy.d/sentry.hookindex 9bb5a84bb24..f692c363aa2 100755--- a/puppet/zulip/files/hooks/pre-deploy.d/sentry.hook+++ b/puppet/zulip/files/hooks/pre-deploy.d/sentry.hook@@ -1,6 +1,4 @@#!/usr/bin/env bash-# Arguments: OLD_COMMIT NEW_COMMIT ...where both are `git describe`-# output or tag names. The CWD will be the new deploy directory.set -eset -u@@ -42,8 +40,6 @@ if ! which sentry-cli >/dev/null; thenexit 0fi-new_version="$2"-merge_base=""if [ "$(git rev-parse --is-inside-work-tree 2>/dev/null || true)" = "true" ]; then# Extract the merge-base that tools/cache-zulip-git-version@@ -57,7 +53,7 @@ if [ "$(git rev-parse --is-inside-work-tree 2>/dev/null || true)" = "true" ]; thfifi-sentry_release="zulip-server@$new_version"+sentry_release="zulip-server@$ZULIP_NEW_VERSION"echo "$sentry_release" >./sentry-releaseecho "sentry: Creating release $sentry_release"diff --git a/scripts/lib/upgrade-zulip-stage-2 b/scripts/lib/upgrade-zulip-stage-2index 579d6195dda..67a39e0e98c 100755--- a/scripts/lib/upgrade-zulip-stage-2+++ b/scripts/lib/upgrade-zulip-stage-2@@ -29,6 +29,7 @@ from scripts.lib.zulip_tools import (assert_running_as_root,get_config,get_config_file,+ get_zulip_pwent,listening_publicly,parse_os_release,parse_version_from,@@ -445,11 +446,22 @@ def run_hooks(kind: Literal["pre-deploy", "post-deploy"]) -> None:path = f"/etc/zulip/hooks/{kind}.d"if not os.path.exists(path):return+ # Pass in, via environment variables, the old/new "version+ # string" (which is a `git describe` output)+ env = os.environ.copy()+ env["ZULIP_OLD_VERSION"] = old_version+ env["ZULIP_NEW_VERSION"] = NEW_ZULIP_VERSION++ # preexec_fn=su_to_zulip normally handles this, but our explicit+ # env overrides that+ env["HOME"] = get_zulip_pwent().pw_dir+for script_name in sorted(f for f in os.listdir(path) if f.endswith(".hook")):subprocess.check_call(- [os.path.join(path, script_name), old_version, NEW_ZULIP_VERSION],+ [os.path.join(path, script_name)],cwd=deploy_path,preexec_fn=su_to_zulip,+ env=env,)