Sobes.tech
Junior

Where does the runner get the code from?

sobes.tech AI

Answer from AI

The runner obtains the code from the version control system repository. Depending on the configuration and the type of runner, this can be:

  • Local file path: If the repository is on the same machine or accessible via a network path.
  • Git repository: The most common method. The runner clones the repository specified in the pipeline job configuration. It uses authentication data (SSH keys, tokens) provided in the runner settings or environment variables.
  • Archive (zip, tar.gz): Less common, but possible if the code is pre-packaged and accessible via URL or local path.

Example from GitLab CI:

# .gitlab-ci.yml
stages:
  - build

build_job:
  stage: build
  script:
    - echo "Cloning repository..."
    - git clone $CI_REPOSITORY_URL .
    - echo "Code obtained."

In this case, the runner clones the repository specified in the $CI_REPOSITORY_URL environment variable, which is automatically provided by GitLab CI.

Example from GitHub Actions:

# .github/workflows/main.yml
name: Build

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout code
      uses: actions/checkout@v4 # This action clones the repository
    - name: Run something
      run: |
        echo "Code obtained."
        # Further steps with the code

In GitHub Actions, the standard actions/checkout action is often used to clone the repository.

Thus, the main mechanism is cloning the repository using the appropriate protocols (git, ssh, https) and authentication data.