From: Matthias Kruk Date: Fri, 26 Nov 2021 11:36:21 +0000 (+0900) Subject: include/msg/build: Add ref field X-Git-Url: https://git.corax.cc/?a=commitdiff_plain;h=be50eb5f32e5138a00dd276369129be64c591fd5;p=foundry include/msg/build: Add ref field Build messages don't carry a field that identifies the version of the built software at the source-code level. This commit adds the "ref" field to the build message specification and implementation. --- diff --git a/include/msg/build.sh b/include/msg/build.sh index 1ca0e2d..fc08082 100644 --- a/include/msg/build.sh +++ b/include/msg/build.sh @@ -14,8 +14,9 @@ foundry_msg_build_new() { local context="$1" local repository="$2" local branch="$3" - local result="$4" - local -n __foundry_msg_build_new_artifacts="$5" + local ref="$4" + local result="$5" + local -n __foundry_msg_build_new_artifacts="$6" local artifact_array local json @@ -28,6 +29,7 @@ foundry_msg_build_new() { if ! json=$(json_object "context" "$context" \ "repository" "$repository" \ "branch" "$branch" \ + "ref" "$ref" \ "result" "$result" \ "artifacts" "$artifact_array"); then return 1 @@ -80,6 +82,19 @@ foundry_msg_build_get_branch() { return 0 } +foundry_msg_build_get_ref() { + local msg="$1" + + local ref + + if ! ref=$(foundry_msg_get_data_field "$msg" "ref"); then + return 1 + fi + + echo "$ref" + return 0 +} + foundry_msg_build_get_result() { local msg="$1" diff --git a/spec/build.json b/spec/build.json index 2a1ea32..ef6c9e6 100644 --- a/spec/build.json +++ b/spec/build.json @@ -21,6 +21,12 @@ "type": "string" }, + "ref": { + "description": "Identifier of the source code version", + "type": "string", + "pattern": "^[0-9a-fA-F]+$" + }, + "artifacts": { "description": "The files resulting from the build", "type": "array", @@ -35,6 +41,7 @@ "context", "repository", "branch", + "ref", "artifacts" ],