Skip to content

Commit c1af185

Browse files
committed
[GitLab CI] Improve env var setting
Allow env vars to either be set with or without CUSTOM_ENV_ prefix. The prefix is added automatically by GitLab if the var is set from the UI. If the variable is set from the container, it is not prefixed. Both approaches are valid so support both.
1 parent 3b0e9ce commit c1af185

3 files changed

Lines changed: 13 additions & 13 deletions

File tree

GitLab/custom-executor.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ To do that:
5959

6060
The provided scripts expect the following environment variables to be set:
6161

62-
- `CUSTOM_ENV_ORKA_TOKEN` - User authentication to connect to the Orka environment. Created by running `orka3 user get-token` or `orka3 serviceaccount token <service-account>`.
63-
- `CUSTOM_ENV_ORKA_ENDPOINT` - The Orka endpoint. Usually, it is `http://10.221.188.20`.
64-
- `CUSTOM_ENV_ORKA_CONFIG_NAME` - The name of the VM config to be deployed.
65-
- `CUSTOM_ENV_ORKA_VM_NAME_PREFIX` - The prefix of the generated VM name. Defaults to `gl-runner`.
66-
- `CUSTOM_ENV_ORKA_VM_USER` - User used to SSH to the VM.
67-
- `CUSTOM_ENV_ORKA_SSH_KEY_FILE` - The private SSH key contents to use when connecting to the VM. This key was created earlier during the Orka base image setup.
68-
- `CUSTOM_ENV_VM_DEPLOYMENT_ATTEMPTS` - The number of attempts the executor tries to deploy a VM before it fails. Defaults to `1`. Note - GitLab automatically retries 3 times. This env var allows additional retry attempts.
62+
- `ORKA_TOKEN` - User authentication to connect to the Orka environment. Created by running `orka3 user get-token` or `orka3 serviceaccount token <service-account>`.
63+
- `ORKA_ENDPOINT` - The Orka endpoint. Usually, it is `http://10.221.188.20`.
64+
- `ORKA_CONFIG_NAME` - The name of the VM config to be deployed.
65+
- `ORKA_VM_NAME_PREFIX` - The prefix of the generated VM name. Defaults to `gl-runner`.
66+
- `ORKA_VM_USER` - User used to SSH to the VM. Defaults to `admin`.
67+
- `ORKA_SSH_KEY_FILE` - The private SSH key contents to use when connecting to the VM. This key was created earlier during the Orka base image setup.
68+
- `VM_DEPLOYMENT_ATTEMPTS` - The number of attempts the executor tries to deploy a VM before it fails. Defaults to `1`. Note - GitLab automatically retries 3 times. This env var allows additional retry attempts.
6969

7070
For more information about GitLab CI/CD environment variables, see [here][env-variables].
7171

GitLab/scripts/base.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
BUILD_ID="runner-$CUSTOM_ENV_CI_RUNNER_ID-project-$CUSTOM_ENV_CI_PROJECT_ID-concurrent-$CUSTOM_ENV_CI_CONCURRENT_PROJECT_ID"
44
export CONNECTION_INFO_ID=$BUILD_ID-connection-info
55

6-
export ORKA_TOKEN=${CUSTOM_ENV_ORKA_TOKEN:-}
7-
export ORKA_ENDPOINT=${CUSTOM_ENV_ORKA_ENDPOINT:-}
8-
export ORKA_CONFIG_NAME=${CUSTOM_ENV_ORKA_CONFIG_NAME:-}
9-
export ORKA_VM_NAME_PREFIX=${CUSTOM_ENV_ORKA_VM_NAME_PREFIX:-gl-runner}
10-
export ORKA_VM_USER=${CUSTOM_ENV_ORKA_VM_USER:-admin}
6+
export ORKA_TOKEN=${ORKA_TOKEN:-${CUSTOM_ENV_ORKA_TOKEN:-}}
7+
export ORKA_ENDPOINT=${ORKA_ENDPOINT:-${CUSTOM_ENV_ORKA_ENDPOINT:-}}
8+
export ORKA_CONFIG_NAME=${ORKA_CONFIG_NAME:-${CUSTOM_ENV_ORKA_CONFIG_NAME:-}}
9+
export ORKA_VM_NAME_PREFIX=${ORKA_VM_NAME_PREFIX:-${CUSTOM_ENV_ORKA_VM_NAME_PREFIX:-gl-runner}}
10+
export ORKA_VM_USER=${ORKA_VM_USER:-${CUSTOM_ENV_ORKA_VM_USER:-admin}}
1111
ORKA_SSH_KEY_FILE=${CUSTOM_ENV_ORKA_SSH_KEY_FILE:-}
1212

1313
mkdir -p ~/.ssh

GitLab/scripts/prepare.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ currentDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
66

77
source "${currentDir}/base.sh"
88

9-
VM_DEPLOYMENT_ATTEMPTS=${CUSTOM_ENV_VM_DEPLOYMENT_ATTEMPTS:-1}
9+
VM_DEPLOYMENT_ATTEMPTS=${VM_DEPLOYMENT_ATTEMPTS:-${CUSTOM_ENV_VM_DEPLOYMENT_ATTEMPTS:-1}}
1010

1111
function cleanup_on_failure {
1212
if [ -f "$BUILD_ID" ]; then

0 commit comments

Comments
 (0)