#Default runner git commands
8 messages · Page 1 of 1 (latest)
Are you referring to git-related commands? That might provide some insights (without looking at the code base): https://docs.gitlab.com/ci/runners/configure_runners/#configure-runner-behavior-with-variables
GitLab product documentation.
Been looking at that but still none the wiser
looking at https://gitlab.com/gitlab-org/gitlab-runner/-/blob/main/shells/abstract.go (I'm terrible at reading Golang), by default it should be something like git -c http.userAgent=[runner-info] fetch origin --no-recurse-submodules --depth 50 if I remember correctly
hm... why not ask GitLab Duo 😄
wow, ok, that was deep
Based on the code in shells/abstract.go, the GitLab Runner executes the following default commands to fetch a project:
-
Initialize Git Environment:
- Sets
GIT_TERMINAL_PROMPT=0andGCM_INTERACTIVE=Neverto prevent interactive prompts - Configures SSL settings if needed
- Sets
-
Repository Setup:
- Creates a temporary Git template directory
- Configures Git template settings:
git config -f templateFile init.defaultBranch nonegit config -f templateFile fetch.recurseSubmodules falsegit config -f templateFile credential.interactive nevergit config -f templateFile gc.autoDetach false
- Initializes Git repository with
git init projectDir --template templateDir
-
Remote Configuration:
- Adds or updates the remote:
git remote add/set-url origin [URL]
- Adds or updates the remote:
-
Fetching Code:
-
Fetches from origin with custom user agent:
git -c http.userAgent=[runner-info] fetch origin --no-recurse-submodules [refspecs]Insert at cursor
-
Adds
--depth [value]if shallow clone is configured -
Handles unshallow fetches if needed
-
-
Checkout:
- Checks out the specific commit:
git checkout -f -q [SHA] - Runs
git cleanwith configured flags if specified
- Checks out the specific commit:
-
Submodule Handling (if enabled):
- Initializes submodules:
git submodule init - Syncs submodule configuration:
git submodule sync [--recursive] - Updates submodules:
git submodule update --init [--recursive] [--depth N] - Cleans submodules:
git submodule foreach git clean -ffdx - Resets submodules:
git submodule foreach git reset --hard
- Initializes submodules:
The exact commands can vary based on configuration options like Git strategy (clone/fetch/none), submodule strategy, depth settings, and various feature flags.
and when I asked to clarify what would be the default:
Based on the code in shells/abstract.go, the default commands that the GitLab Runner executes to fetch a project are:
-
Environment Setup:
export GIT_TERMINAL_PROMPT=0 export GCM_INTERACTIVE=Never -
Git Template Configuration:
git config -f templateFile init.defaultBranch none git config -f templateFile fetch.recurseSubmodules false git config -f templateFile credential.interactive never git config -f templateFile gc.autoDetach false -
Repository Initialization:
`git init projectDir --template templateDir` -
Remote Configuration:
git remote add origin remoteURL # or if remote already exists git remote set-url origin remoteURL -
Fetching Code:
`git -c http.userAgent=[runner-info] fetch origin --no-recurse-submodules [refspecs]`- With depth parameter if specified:
--depth [value] - With unshallow parameter if needed:
--unshallow
- With depth parameter if specified:
-
Checkout:
`git -c submodule.recurse=false checkout -f -q [SHA]` -
Cleaning (if configured):
`git clean [flags]`
These commands are executed in sequence as part of the writeRefspecFetchCmd and related methods in the AbstractShell implementation, with variations based on configuration options like Git strategy, depth settings, and other feature flags.
Give feedback to improve this answer.
Thank you 🙏