feat: set the CI_SERVER_SHELL_SSH_HOST predefined variable

Merged
CR
9d ago
+3-0

Closes #1972.

GitLab defines CI_SERVER_SHELL_SSH_HOST, the SSH host of the instance for Git access, next to CI_SERVER_SHELL_SSH_PORT. gitlab-ci-local only defined the port, so scripts that clone with git@$CI_SERVER_SHELL_SSH_HOST:... got an empty host.

CI_SERVER_SHELL_SSH_HOST now defaults to CI_SERVER_HOST, which is also GitLab's value unless a separate SSH host is configured. Like the other CI_SERVER_* variables, it can be overridden with --variable or a variables file.

Tests:

  • Added CI_SERVER_SHELL_SSH_HOST: "gitlab.com" to the expected variables in tests/test-cases/predefined-variables/integration.test.ts. I couldn't run that suite locally: the shell executor needs rsync, which isn't available on my Windows machine, so I'm relying on CI for it.
  • Called init() from predefined-variables.ts directly, with an SSH remote on gitlab.example.com:2222:
    • no overrides: CI_SERVER_SHELL_SSH_HOST=gitlab.example.com
    • CI_SERVER_HOST=gitlab.internal: CI_SERVER_SHELL_SSH_HOST=gitlab.internal
    • CI_SERVER_SHELL_SSH_HOST=ssh.gitlab.example.com: that value, with CI_SERVER_HOST unchanged
  • eslint and tsc --noEmit are clean.

Summary by cubic

Defines the CI_SERVER_SHELL_SSH_HOST predefined variable so scripts that clone with git@$CI_SERVER_SHELL_SSH_HOST no longer get an empty host.

  • The variable defaults to CI_SERVER_HOST, matching GitLab's behavior unless a separate SSH host is configured, and can be overridden with --variable or a variables file.
  • Updates the predefined-variables integration test to expect the new variable.

Closes #1972.