You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
That is ugly! It would be nice to have a variable like CI_SERVICE_PREFIX available in all jobs as a preset environment variable so steps could use it to find services, and CI versions of config files could reference it directly.
Update instead of a prefix, how about generating a FQDN? Yeah. Let's do that.
The text was updated successfully, but these errors were encountered:
I tried a few approaches to this. For posterity, here is one I abandoned that may come in handy later if we need to have a persistent variable set on the manager side that is visible to all scripts (prepare.sh, run.sh, etc):
config.sh:
#!/usr/bin/env bash## Generate custom configuration JSON - https://docs.gitlab.com/runner/executors/custom.html#config# STDOUT needs to be well formed JSON or this gets ignored.
currentDir="$(cd"$( dirname "${BASH_SOURCE[0]}")">/dev/null 2>&1&&pwd)"source"${currentDir}/base.sh"# Get variables from base.
SERVICE_PREFIX="${CONTAINER_ID}-svc-"
CUSTOM_ENVIRONMENT=()
if [ -n"$CUSTOM_ENV_CI_JOB_SERVICES" ];then
CUSTOM_ENVIRONMENT+=$(echo "$CUSTOM_ENV_CI_JOB_SERVICES"| jq ".[] | {(\"CUSTOM_ENV_SERVICE_\" + .alias): (\"${SERVICE_PREFIX}\" + .alias + \".apps.internal\")}")fiif [[ -z${CUSTOM_ENVIRONMENT[@]} ]];thenexit 0
fiecho"[cf-driver] Adding configuration from config.sh"1>&2
cat <<EOS{ "job_env" : $(echo${CUSTOM_ENVIRONMENT[@]}| jq -s 'add')}EOS
To use this you also need to setup use of a config_exec step by setting the CUSTOM_CONFIG_EXEC variable to "/home/vcap/app/cf-driver/config.sh" in /manifest.yml.
If you use this read the linked documentation carefully. It does not populate variables into the jobs.
pauldoomgov
changed the title
Populate a CI_SERVICE_PREFIX from the worker side to allow easy reference from .gitlab-ci.yml
Populate a CI_SERVICE_alias from the worker side for each service to allow easy reference from .gitlab-ci.yml
Aug 2, 2024
With #5 we added service workers but calculating the hostname inside gitlab-ci.yml requires this mess:
That is ugly! It would be nice to have a variable like
CI_SERVICE_PREFIX
available in all jobs as a preset environment variable so steps could use it to find services, and CI versions of config files could reference it directly.Update instead of a prefix, how about generating a FQDN? Yeah. Let's do that.
The text was updated successfully, but these errors were encountered: