Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: error checking for initial API token call #1080

Merged
merged 3 commits into from
Feb 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 11 additions & 3 deletions template/gitlab-runner.tftpl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ then
# fetch gitlab token from SSM
gitlab_token=$(aws ssm get-parameter --name "${secure_parameter_store_gitlab_token_name}" --with-decryption --region "${secure_parameter_store_region}" | jq -r ".Parameter | .Value")

token=$(curl ${curl_cacert} --request POST -L "${runners_gitlab_url}/api/v4/user/runners" \
response = $(curl ${curl_cacert} --request POST -L "${runners_gitlab_url}/api/v4/user/runners" \
--header "private-token: $gitlab_token" \
--form "tag_list=${gitlab_runner_tag_list}" \
--form "description=${gitlab_runner_description}" \
Expand All @@ -58,8 +58,16 @@ then
--form "maximum_timeout=${gitlab_runner_maximum_timeout}" \
--form "runner_type=${gitlab_runner_type}_type" \
$runner_type_param \
--form "access_level=${gitlab_runner_access_level}" \
| jq -r '.token')
--form "access_level=${gitlab_runner_access_level}")

token = $(echo response | jq -r '.token')
if [[ "$token" == null ]]
message = $(echo response | jq -r '.message // .error_description')
if [[ "$message" != null ]]
echo "ERROR: Couldn't register the Runner. GitLab API call returned $message".
exit 1
fi
fi
else
gitlab_runner_registration_token=${gitlab_runner_registration_token}

Expand Down