Skip to content

Implement GIT_CHECKOUT_STRATEGY (#15409)

What does this MR do?

This MR adds a GIT_CHECKOUT_STRATEGY variable, with two configurable options:

  • DETACHED (default)
  • BRANCH

When set to DETACHED, the gitlab-runner behaves the same as today. However, when set to BRANCH the checkout command is updated to checkout the branch and not the detached commit SHA.

Documentation MR can be found here.

Why was this MR needed?

It is not currently possible to checkout the branch in non-detached state, without manually running git checkout $CI_COMMIT_BRANCH. If you are using Docker/Kubernetes executors this causes unnecessary pain as you need to make sure git is available within the container.

Not being able to checkout the code in a non-detached state causes issues in certain circumstances, one such example is a maven pipeline that are uses the jgitflow plugin.

What's the best way to test this MR?

What are the relevant issue numbers?

#15409

Edited by Richard Jones

Merge request reports