diff options
author | Sascha Roloff <sascha.roloff@huawei.com> | 2025-05-08 13:39:53 +0200 |
---|---|---|
committer | Sascha Roloff <sascha.roloff@huawei.com> | 2025-05-08 16:32:18 +0200 |
commit | dd6be011609937477516344d217a24aadf92fcd2 (patch) | |
tree | 5801534afd5f88e1d1ad84453630909bf46b89a8 /src/other_tools/just_mr/launch.cpp | |
parent | a10dd9a098cc0887e27da17496a7b18a31f131c7 (diff) | |
download | justbuild-dd6be011609937477516344d217a24aadf92fcd2.tar.gz |
Invocation logging: add new field context variables
It allows to specify a list of environment variables, which are captured at
invocation time and stored as key-value pairs in the metadata file. This allows
to get some information about the invocation context such as username,
merge-request ID or source branch (on a CI runner), or others.
Diffstat (limited to 'src/other_tools/just_mr/launch.cpp')
-rw-r--r-- | src/other_tools/just_mr/launch.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/other_tools/just_mr/launch.cpp b/src/other_tools/just_mr/launch.cpp index ca21e268..dc861c11 100644 --- a/src/other_tools/just_mr/launch.cpp +++ b/src/other_tools/just_mr/launch.cpp @@ -371,6 +371,15 @@ auto CallJust(std::optional<std::filesystem::path> const& config_file, meta["configuration"] = mr_config_pair->second; } meta["cmdline"] = cmd; + if (not invocation_log.context_vars.empty()) { + auto context = nlohmann::json::object(); + for (auto const& env_var : invocation_log.context_vars) { + auto* env_value = std::getenv(env_var.c_str()); + context[env_var] = + env_value != nullptr ? env_value : nlohmann::json{}; + } + meta["context"] = context; + } // "configuration" -- the blob-identifier of the multi-repo // configuration auto file_name = *log_dir / *invocation_log.metadata; |