Skip to content

Expose runner environment variables to gitlab-runner installation scripts #111

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

Open
UiP9AV6Y opened this issue Apr 20, 2025 · 5 comments · May be fixed by #113 or #116
Open

Expose runner environment variables to gitlab-runner installation scripts #111

UiP9AV6Y opened this issue Apr 20, 2025 · 5 comments · May be fixed by #113 or #116

Comments

@UiP9AV6Y
Copy link
Contributor

As part of the VM provisioning, the tart-executor installs gitlab-runner as it is one the of prerequisits for the build environment. tart-executor supports two strategies; downloading via curl or brew

We use an internal homebrew cache in order to speed up the usage of brew as part of our CI environment. For this to work, we define HOMEBREW_ARTIFACT_DOMAIN and HOMEBREW_DOCKER_REGISTRY_TOKEN as executor environment variables. These variables are available throughout every custom executor stage but are not forwarded to any logic happening inside the VM; only the build stage receives them as gitlab-runner exposes them as part of the build script via a series of export statements.

In order for the gitlab-runner installation as part of the preparation phase to benefit from our internal cache, i would like to see the environment variables also forwarded to the installation script.

Another usecase could be the use of HTTP proxies. Assuming a build environment has restricted access to the internet, both the curl as well as brew installation would fail. In this case the runner would be provisioned with HTTP_PROXY variables which would also be needed during the gitlab-runner installation step.

The environment variables are already processed as part of the gitlab.InitEnv() function, but most of the values are discarded.

ssh#Session.Setenv

setting the environment using Setenv for the installation script session would solve the issue

pro: the installation scripts must not be changed
contra: sshd might be configured to reject or/some environment variables

export

injecting the environment variables into the installation scripts would closely resemble the logic gitlab-runner does for the build stage.

pro: the sshd configuration has no impact on the functionality
contra: -

@UiP9AV6Y
Copy link
Contributor Author

if this feature request is accepted, i can come up with a PR implementing the changes

@edigaryev
Copy link
Contributor

I think export is the way to go, since Setenv() requires additional configuration on the SSH server's side. In fact, we already do this in Cirrus CLI.

Do you want to re-export all variables starting with CUSTOM_ENV_ to the SSH session, stripping the prefix?

@UiP9AV6Y
Copy link
Contributor Author

Do you want to re-export all variables starting with CUSTOM_ENV_ to the SSH session, stripping the prefix?

essentially, yes

@edigaryev
Copy link
Contributor

Do you want to re-export all variables starting with CUSTOM_ENV_ to the SSH session, stripping the prefix?

essentially, yes

SGTM.

/cc @fkorotkov

@fkorotkov
Copy link
Contributor

SGTM too

UiP9AV6Y added a commit to UiP9AV6Y/gitlab-tart-executor that referenced this issue Apr 23, 2025
* merge the various installation scripts into a single one
* use text/template to render the actual script based on user/operator input
* implement unit tests for test coverage of new feature

closes cirruslabs#111
UiP9AV6Y added a commit to UiP9AV6Y/gitlab-tart-executor that referenced this issue Apr 23, 2025
* merge the various installation scripts into a single one
* use text/template to render the actual script based on user/operator input
* implement unit tests for test coverage of new feature

closes cirruslabs#111
UiP9AV6Y added a commit to UiP9AV6Y/gitlab-tart-executor that referenced this issue Apr 23, 2025
* merge the various installation scripts into a single one
* use text/template to render the actual script based on user/operator input
* implement unit tests for test coverage of new feature

closes cirruslabs#111
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants