#Default runner git commands

8 messages · Page 1 of 1 (latest)

empty mica
#

What are the default commands that the gitlab runner executes to fetch the project?

sonic remnant
empty mica
#

Been looking at that but still none the wiser

scenic merlin
#

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:

  1. Initialize Git Environment:

    • Sets GIT_TERMINAL_PROMPT=0 and GCM_INTERACTIVE=Never to prevent interactive prompts
    • Configures SSL settings if needed
  2. Repository Setup:

    • Creates a temporary Git template directory
    • Configures Git template settings:
      • 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
    • Initializes Git repository with git init projectDir --template templateDir
  3. Remote Configuration:

    • Adds or updates the remote: git remote add/set-url origin [URL]
  4. 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

  5. Checkout:

    • Checks out the specific commit: git checkout -f -q [SHA]
    • Runs git clean with configured flags if specified
  6. 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

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:

  1. Environment Setup:

        export GIT_TERMINAL_PROMPT=0
        export GCM_INTERACTIVE=Never
    
  2. 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
    
  3. Repository Initialization:

    `git init projectDir --template templateDir`
    
  4. Remote Configuration:

        git remote add origin remoteURL
        # or if remote already exists
        git remote set-url origin remoteURL
    
  5. 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
  6. Checkout:

    `git -c submodule.recurse=false checkout -f -q [SHA]`
    
  7. 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.

empty mica
#

Thank you 🙏