Junior
Where does the runner get the code for execution?
sobes.tech AI
Answer from AI
Runner retrieves the code to execute from the version control system repository, usually via a protocol such as Git. The specific repository URL and branch (or tag, commit) are specified in the pipeline configuration that triggers this runner.
The retrieval process may look like this:
- The Runner receives a command to execute a task from a CI/CD orchestrator (e.g., GitLab CI/CD, GitHub Actions, Jenkins).
- Along with the command, information about the task is transmitted, including the repository link, branch/commit, and execution context.
- The Runner performs a clone operation of the repository (or its part) into its local temporary workspace.
- After a successful clone, the runner switches to the specified commit, branch, or tag, ensuring work with the required version of the code.
Example of a clone command in GitLab CI:
# Cloning the repository specified in the CI_REPOSITORY_URL variable
git clone "$CI_REPOSITORY_URL" "$CI_BUILDS_DIR/$CI_PROJECT_NAME"
# Changing to the project directory
cd "$CI_BUILDS_DIR/$CI_PROJECT_NAME"
# Checking out the required commit
git checkout "$CI_COMMIT_SHA"
In some cases, with caching enabled, the runner may first check for a local copy of the repository and only perform git fetch and git checkout to update to the needed state, instead of cloning the entire repository.
The configuration defining the source code is usually specified in a YAML file describing the pipeline (e.g., .gitlab-ci.yml, .github/workflows/*.yml).