forked from ruanbekker/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgitlab_runner_shell_executor.sh
More file actions
23 lines (20 loc) · 947 Bytes
/
gitlab_runner_shell_executor.sh
File metadata and controls
23 lines (20 loc) · 947 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env bash
# Description:
# This will register a gitlab runner with a shell executor,
# fetchting the registration token from SSM, and resulting in a name like:
# aws-myproject-shell-09af
# Pre-Reqs:
# Ensure the aws profile has access to ssm:GetParameters and kms:Decrypt
# Run this as root
GITLAB_URL="https://gitlab.mydomain.com/gitlab/"
GITLAB_GROUP_NAME="myproject"
GITLAB_RUNNER_EXECUTOR="shell"
GITLAB_RUNNER_SUFFIX="$(openssl rand -hex 2)"
GITLAB_RUNNER_REGISTRATION_TOKEN="$(aws ssm get-parameter --name \"/gitlab-runners/${GITLAB_GROUP_NAME}/RUNNER_REGISTRATION_TOKEN\" --with-decryption | jq -r '.Parameter.Value')"
gitlab-runner register \
--non-interactive \
--name "aws-${GITLAB_GROUP_NAME}-${GITLAB_RUNNER_EXECUTOR}-${GITLAB_RUNNER_SUFFIX}" \
--url "${GITLAB_URL}" \
--registration-token "${GITLAB_RUNNER_REGISTRATION_TOKEN}" \
--executor "${GITLAB_RUNNER_EXECUTOR}" \
--tag-list "${GITLAB_RUNNER_EXECUTOR}"