Skip to content

GitLab Next

    • GitLab: the DevOps platform
    • Explore GitLab
    • Install GitLab
    • How GitLab compares
    • Get started
    • GitLab docs
    • GitLab Learn
  • Pricing
  • Talk to an expert
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Menu
    Projects Groups Snippets
  • Get a free trial
  • Sign up
  • Login
  • Sign in / Register
  • gitlab-runner gitlab-runner
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 2,398
    • Issues 2,398
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Merge requests 134
    • Merge requests 134
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Monitor
    • Monitor
    • Metrics
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar

GitLab 15.0 is launching on May 22! This version brings many exciting improvements, but also removes deprecated features and introduces breaking changes that may impact your workflow. To see what is being deprecated and removed, please visit Breaking changes in 15.0 and Deprecations.

  • GitLab.org
  • gitlab-runnergitlab-runner
  • Merge requests
  • !876
Project 'gitlab-org/gitlab-ce' was moved to 'gitlab-org/gitlab-foss'. Please update any links and bookmarks that may still have the old path.
The source project of this merge request has been removed.
Closed
Created Apr 12, 2018 by Steve Azzopardi@steveazzMaintainer4 of 7 tasks completed4/7 tasks

Add custom clone path for the build

  • Overview 124
  • Changes 16

What does this MR do?

Add custom clone path for the build

When the user specifies CI_PROJECT_DIR environment variable inside of the .gitlab-ci.yml if the path is valid it is used to clone and build.

CI_PROJECT_DIR takes precedence over the configured build dir and the default build dir.

This is not available when shared dir are enabled meaning:

  • Docker executor has a mounted volume
  • Shell executor
  • SSH executor

Closes #2211 (closed)

Implementation Reasons

CI_PROJECT_DIR was a variable that already exists where the full path of the repository is cloned and where the job is run. Allowing the user to define this and use it seems like the least amount of code changes and something the users are already used/familiar with.

Another option is to introduce the git key when you define a stage. Where the clone key defines which directory the runner should use to clone and build. In theory, we could reuse git key for future git customization we might want. Adding the key seems like adding extra complexity to using the runner, one more key to document, show how the user to use it and more configuration point the user has to keep track of. Also, this would have to be defined at every stage whilst the CI_PROJECT_DIR can be defined once under the variables key you want it across all stages.

build:
    image: golang:1.10-alpine3.7
    stage: build
    script:
        - go build -v -o app
    git:
      clone: "/go/src/gitlab.com/gitlab.org/gitlab-runner"

Why was this MR needed?

Some builds require the code to be checked out in a specific directory, such as GO it requires you to have your code in the specified $GOPATH. The usual way to solve this is to either symlink to the desired directory or move the directory as explained in #2211 (closed).

Allowing the user to specify which directory the code needs to be cloned and build will help prevent this and other issues like this one

Are there points in the code the reviewer needs to double check?

  • Shared directory, to my knowledge if it is running on an executor with shared directories a unique directory for each build needs to be created to prevent conflicts. Is this true?

How to Test

Below is a simple gitlab-ci.yml file to help manually testing

image: golang:1.10-alpine3.7

variables:
  CI_PROJECT_DIR: /go/src/gitlab.com/test-namespace/2211-custom-clone-path

stages:
    - test

dir:
    stage: test
    script:
      - pwd
      - ls -la /go/src/gitlab.com/test-namespace/2211-custom-clone-path

Questions

  • Should we update gitlab-ci.yml templates to reflect this change?

BLOCKERS

Blocked by:

  • #3505
  • #3506

Does this MR meet the acceptance criteria?

  • Documentation created/updated gitlab-org/gitlab-ce!19664 (the old, reverted one)
  • Documentation created/updated: gitlab-ce!20427
  • Tests
    • Added for this feature/bug
    • All builds are passing
  • Branch has no merge conflicts with master (if you do - rebase it please)

What are the relevant issue numbers?

Closes #2211 (closed)

Edited Mar 27, 2019 by Tomasz Maczukin
Assignee
Assign to
Reviewer
Request review from
Time tracking
Source branch: 2211-add-option-to-change-clone-path