From 7be169177d09b244aa912f385dd742c3be8de1ec Mon Sep 17 00:00:00 2001 From: Florian Uhlig <f.uhlig@gsi.de> Date: Tue, 27 Aug 2024 10:56:54 +0200 Subject: [PATCH] Fail script in case of invalid token --- scripts/inform_codeowners.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/inform_codeowners.sh b/scripts/inform_codeowners.sh index 6d27d5d0a8..42472a18ba 100755 --- a/scripts/inform_codeowners.sh +++ b/scripts/inform_codeowners.sh @@ -151,6 +151,14 @@ function generate_file_list() { function generate_comment() { + # Fail the test if token isn't valid + MRINFO=$(curl -s --request GET --header "PRIVATE-TOKEN: $COMMENT_TOKEN" "https://git.cbm.gsi.de/api/v4/projects/$CI_MERGE_REQUEST_PROJECT_ID/merge_requests/$CI_MERGE_REQUEST_IID") + MRINFO_1=$(echo $MRINFO | grep project_id) + if [[ -z $MRINFO_1 ]]; then + echo "Invalid token. Stop execution" + exit 1 + fi + # Get Information about the MR in JSON format # Check if the returned string contains the signature that the CodeOwners label is set # Only create GitLab comment if there is no comment yet (CodeOwners label not set) -- GitLab