From ec444e09f57e4b0e552ba77f1e678993d5ed9587 Mon Sep 17 00:00:00 2001 From: Mark Pundsack Date: Thu, 16 Jun 2016 13:15:50 -0700 Subject: Add GIT_STRATEGY and GIT_DEPTH --- doc/ci/yaml/README.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/doc/ci/yaml/README.md b/doc/ci/yaml/README.md index 9c98f9c98c6..51c6f814c00 100644 --- a/doc/ci/yaml/README.md +++ b/doc/ci/yaml/README.md @@ -814,6 +814,43 @@ job: - execute this after my script ``` +## Git Strategy + +>**Note:** +Introduced in GitLab 8.9 as an experimental feature + +You can set the `GIT_STRATEGY` used for getting recent application code. `clone` +is slower, but makes sure you have a clean directory before every build. `fetch` +is faster. If specified, it will override the project settings in the web UI. + +``` +variables: + GIT_STRATEGY: clone +``` + +or + +``` +variables: + GIT_STRATEGY: fetch +``` + +## Shallow cloning + +>**Note:** +Introduced in GitLab 8.9 as an experimental feature + +You can specify the depth of fetching and cloning using `GIT_DEPTH`. This allows +shallow cloning of the repository. The value is passed to `git fetch` and `git +clone`. If set while cloning, it will imply `--shallow-modules`, which means +submodules will be cloned with a depth of 1 regardless of the value of +`GIT_DEPTH`. + +``` +variables: + GIT_DEPTH: "1" +``` + ## Hidden jobs >**Note:** -- cgit v1.2.1 From da6d148c3ff43c5b74f7d30896483b2708ccb8cd Mon Sep 17 00:00:00 2001 From: Mark Pundsack Date: Thu, 16 Jun 2016 13:55:23 -0700 Subject: Add to TOC --- doc/ci/yaml/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/ci/yaml/README.md b/doc/ci/yaml/README.md index 51c6f814c00..6a64d48e703 100644 --- a/doc/ci/yaml/README.md +++ b/doc/ci/yaml/README.md @@ -35,6 +35,8 @@ If you want a quick introduction to GitLab CI, follow our - [artifacts:expire_in](#artifacts-expire_in) - [dependencies](#dependencies) - [before_script and after_script](#before_script-and-after_script) +- [Git Strategy](#git-strategy) +- [Shallow cloning](#shallow-cloning) - [Hidden jobs](#hidden-jobs) - [Special YAML features](#special-yaml-features) - [Anchors](#anchors) -- cgit v1.2.1 From 4e0f9eeba77d295ac3b2f8c2ef122ff7945bfcce Mon Sep 17 00:00:00 2001 From: Mark Pundsack Date: Thu, 16 Jun 2016 14:04:10 -0700 Subject: Clean up TOC --- doc/ci/yaml/README.md | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/doc/ci/yaml/README.md b/doc/ci/yaml/README.md index 6a64d48e703..4ab587b293b 100644 --- a/doc/ci/yaml/README.md +++ b/doc/ci/yaml/README.md @@ -13,34 +13,34 @@ If you want a quick introduction to GitLab CI, follow our **Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)* - [.gitlab-ci.yml](#gitlab-ci-yml) - - [image and services](#image-and-services) - - [before_script](#before_script) - - [after_script](#after_script) - - [stages](#stages) - - [types](#types) - - [variables](#variables) - - [cache](#cache) - - [cache:key](#cache-key) + - [image and services](#image-and-services) + - [before_script](#before_script) + - [after_script](#after_script) + - [stages](#stages) + - [types](#types) + - [variables](#variables) + - [cache](#cache) + - [cache:key](#cache-key) - [Jobs](#jobs) - - [script](#script) - - [stage](#stage) - - [job variables](#job-variables) - - [only and except](#only-and-except) - - [tags](#tags) - - [when](#when) - - [environment](#environment) - - [artifacts](#artifacts) - - [artifacts:name](#artifacts-name) - - [artifacts:when](#artifacts-when) - - [artifacts:expire_in](#artifacts-expire_in) - - [dependencies](#dependencies) - - [before_script and after_script](#before_script-and-after_script) + - [script](#script) + - [stage](#stage) + - [only and except](#only-and-except) + - [job variables](#job-variables) + - [tags](#tags) + - [when](#when) + - [environment](#environment) + - [artifacts](#artifacts) + - [artifacts:name](#artifactsname) + - [artifacts:when](#artifactswhen) + - [artifacts:expire_in](#artifactsexpire_in) + - [dependencies](#dependencies) + - [before_script and after_script](#before_script-and-after_script) - [Git Strategy](#git-strategy) - [Shallow cloning](#shallow-cloning) - [Hidden jobs](#hidden-jobs) - [Special YAML features](#special-yaml-features) - - [Anchors](#anchors) -- [Validate the .gitlab-ci.yml](#validate-the-gitlab-ci-yml) + - [Anchors](#anchors) +- [Validate the .gitlab-ci.yml](#validate-the-gitlab-ciyml) - [Skipping builds](#skipping-builds) - [Examples](#examples) -- cgit v1.2.1 From 5de95d4e7088a0e1d94c7991d95ddd92a2345459 Mon Sep 17 00:00:00 2001 From: Mark Pundsack Date: Fri, 17 Jun 2016 15:25:32 -0700 Subject: Update GIT_DEPTH wording --- doc/ci/yaml/README.md | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/doc/ci/yaml/README.md b/doc/ci/yaml/README.md index 4ab587b293b..7d2afe4c3fa 100644 --- a/doc/ci/yaml/README.md +++ b/doc/ci/yaml/README.md @@ -819,11 +819,14 @@ job: ## Git Strategy >**Note:** -Introduced in GitLab 8.9 as an experimental feature +Introduced in GitLab 8.9 as an experimental feature. May change in future +releases or be removed completely. You can set the `GIT_STRATEGY` used for getting recent application code. `clone` is slower, but makes sure you have a clean directory before every build. `fetch` -is faster. If specified, it will override the project settings in the web UI. +is faster. `GIT_STRATEGY` can be specified in the global `variables` section or +in the `variables` section for individual jobs. If it's not specified, then the +default from project settings will be used. ``` variables: @@ -840,17 +843,32 @@ variables: ## Shallow cloning >**Note:** -Introduced in GitLab 8.9 as an experimental feature +Introduced in GitLab 8.9 as an experimental feature. May change in future +releases or be removed completely. You can specify the depth of fetching and cloning using `GIT_DEPTH`. This allows -shallow cloning of the repository. The value is passed to `git fetch` and `git -clone`. If set while cloning, it will imply `--shallow-modules`, which means -submodules will be cloned with a depth of 1 regardless of the value of -`GIT_DEPTH`. +shallow cloning of the repository which can significantly speed up cloning for +repositories with a large number of commits or old, large binaries. The value is +passed to `git fetch` and `git clone`. +>**Note:** +If you use a depth of 1 and have a queue of builds or retry +builds, jobs may fail. + +Since Git fetching and cloning is based on a ref, such as a branch name, runners +can't clone a specific commit SHA. If there are multiple builds in the queue, or +you are retrying an old build, the commit to be tested needs to be within the +git history that is cloned. Setting too small a value for `GIT_DEPTH` can make +it impossible to run these old commits. You will see `unresolved reference` in +build logs. You should then reconsider changing `GIT_DEPTH` to a higher value. + +Builds that rely on `git describe` may not work correctly when `GIT_DEPTH` is +set since only part of the git history is present. + +To fetch or clone only the last 3 commits: ``` variables: - GIT_DEPTH: "1" + GIT_DEPTH: "3" ``` ## Hidden jobs -- cgit v1.2.1