Search code examples
yamlgitlab-ci

With GitLab CI how to disable repository clone for one job?


I need to speed up the job 'deploy'. It does not need the sources of the project, but only the artifacts.

How to disable project cloning for the only job?

Typical .gitlab-ci.yml (pseudo) looks like:

image: gcc

build:
  stage: build
  script:
  - ./configure
  - mkdir build && cd $_
  - cmake ..
  - make -sj8
artifacts:
  paths:
  - "build/*.elf"

deploy:
  image: artifactory
  variables:
  - DO_NOT_CLONE: 1  ## WANT THIS OPTION
  stage: deploy
  script:
  - push_artifacts build/*.elf

Solution

  • Checkout the variable GIT_STRATEGY:

    variables:
      GIT_STRATEGY: none
    

    From the documentation:

    none also re-uses the project workspace, but skips all Git operations (including GitLab Runner’s pre-clone script, if present). It is mostly useful for jobs that operate exclusively on artifacts (e.g., deploy).

    https://docs.gitlab.com/ee/ci/runners/configure_runners.html#git-strategy