firecow / gitlab-ci-local

Tired of pushing to test your .gitlab-ci.yml?
MIT License
2.02k stars 114 forks source link

Custom build directories with GIT_CLONE_PATH #1207

Open staehle opened 1 month ago

staehle commented 1 month ago

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:

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 commented 1 month ago

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

firecow commented 1 month ago

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

staehle commented 1 month ago

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