gitlab-ci-local icon indicating copy to clipboard operation
gitlab-ci-local copied to clipboard

Custom build directories with GIT_CLONE_PATH

Open staehle opened this issue 1 year ago • 3 comments

Is your feature request related to a problem? Please describe. Hi! Love this project, however it does not currently work with my GitLab projects where GIT_CLONE_PATH is set, as CI builds in those repos are where they're just a piece of a larger puzzle and I have to clone other items directly in CI_PROJECT_PATH. Basically it just allows the GitLab project being CI'd to start off in a subdirectory.

Describe the solution you'd like Pretty much just what the GitLab docs state for it:

  • https://docs.gitlab.com/ee/user/project/repository/monorepos/#git-clone-path
  • https://docs.gitlab.com/ee/ci/runners/configure_runners.html#custom-build-directories

It just clones the GitLab project into the provided GIT_CLONE_PATH directory instead of the default.

Describe alternatives you've considered Other than manually moving items around, which I'm not too keen on doing.

Additional context Not really, just letting you know this is a feature that's missing! Thanks! :)

staehle avatar May 07 '24 18:05 staehle

On a similar note, CI_BUILDS_DIR is missing. It looks like CI_PROJECT_DIR here is taking it's place, which is not particularly working well for my case of needing to orchestrate multiple repos for a single CI run.

For example on a real GitLab CI run, these are the builtin variables I get:

CI_PROJECT_PATH: firmware/myproject
CI_BUILDS_DIR: /builds
CI_PROJECT_DIR: /builds/firmware/myproject # aka "${CI_BUILDS_DIR}/${CI_PROJECT_PATH}" , at least in my runner setup

And "myproject" is a subcomponent of what we'll call the "super_project", so I need to do a directory shuffle in order to do a build, like so:

variables:
  SUPER_PROJECT_DIR: ${CI_PROJECT_DIR}/super_project  # /builds/firmware/myproject/super_project
  ACTUAL_PROJECT_DIR: ${SUPER_PROJECT_DIR}/myproject  # /builds/firmware/myproject/super_project/myproject
  ARTIFACTS_DIR: ${CI_PROJECT_DIR}/artifacts
script:
  - |
    cd ${CI_BUILDS_DIR}
    mv ${CI_PROJECT_DIR} ${CI_BUILDS_DIR}/tempspace
    mkdir -p ${CI_PROJECT_DIR}
    git clone --depth=1 https://oauth2:${GL_TOKEN}@... ${SUPER_PROJECT_DIR}
    mv ${CI_BUILDS_DIR}/tempspace ${ACTUAL_PROJECT_DIR}
    cd ${ACTUAL_PROJECT_DIR}
    ./do_the_build destination=${ARTIFACTS_DIR}

I can't currently do script step 2 with gitlab-ci-local. So even without GIT_CLONE_PATH support, a workaround like this wouldn't work either

staehle avatar May 08 '24 19:05 staehle

CI_BUILDS_ variables was deprecated in Gitlab 9.0, we will most likely not be implementing variables that are so old. https://gitlab.com/gitlab-org/gitlab/-/issues/352957

firecow avatar May 09 '24 07:05 firecow

CI_BUILD_*, non-plural, yes. CI_BUILDS_DIR is noted as not being deprecated in the very ticket you linked 😅

CI_BUILDS_DIR wouldn't be here otherwise https://docs.gitlab.com/ee/ci/variables/predefined_variables.html , or in various other current docs https://docs.gitlab.com/search/?q=CI_BUILDS_DIR

staehle avatar May 09 '24 15:05 staehle

Closing this a duplicate of https://github.com/firecow/gitlab-ci-local/issues/1330

firecow avatar Nov 22 '24 18:11 firecow