Some builds do not require a git repository to be present - they may proceed using artifacts only (deploy jobs, for instance). To support this use case, we need the runner to understand and implement GIT_STRATEGY=none.
The strategy is currently a project-level option, but it is injected into the runner as a build variable so is amenable to being overriden in .gitlab-ci.yml
Designs
An error occurred while loading designs. Please try again.
Child items
0
Show closed items
GraphQL error: The resource that you are attempting to access does not exist or you don't have permission to perform this action
No child items are currently open.
Linked items
0
Link issues together to show that they're related or that one is blocking others.
Learn more.
The naive way to implement this would be to RmDir(projectDir) && MkDir(projectDir) && Cd(projectDir). However, this interacts badly with the shell executor in the default git fetch scenario.
Imagine a user with a simple buildit -> deployit pipeline. Every time she pushes:
buildit.prepare looks for an existing git repository to fetch from. Not finding it, we execute a clone instead.
buildit.* runs
deployit.prepare removes the directory and creates a new, empty directory
deployit.* runs
repeat
I'll have the prepare script use MkTmpDir to create cwd for such builds instead.
@markpundsack should the PreCloneScript be run if GIT_STRATEGY == none ? I'm leaning towards "no", but not very strongly. We also run it when we're actually doing a git fetch...
I guess it's actually the before_script, in which case I'd say it should be run.
@nick.thomasbefore_script is part of the script. It just easier to write it once and not repeat for each job definition in .gitlab-ci.yml. And this should be executed as it is.
PreCloneScript (which is named like that even if it's executed before git fetch, because PreCloneOrFetchScript name looks a little silly for me 😉) is executed before git/fetch step. I think it shouldn't execute it with GIT_STRATEGY == none. There is no fetch/clone step - there should be no PreCloneScript.
And as for https://gitlab.com/gitlab-org/gitlab-ci-multi-runner/issues/1723#note_16043153: what about doing a mkdir -p /path/to/project/dir; cd /path/to/project/dir (and it CMD/PowerShell replacements) instead of clone/fetch step? If the directory exists it will still exist in unmodified state. If this is a new host and the directory doesn't exists - it will be created, but it will be empty.
In fetch strategy we don't remove anything so I think we could do the same in none strategy. Just skip the git clone/git fetch operation.
I prefer an empty directory to just using the project directory as-is because it's a guaranteed clean state. We can't easily predict the state a projectDir is going to be in, and that will lead to surprises. Purely as an example, perhaps the release script does:
if[-d".git"];then# do dev deployelse# do prod deployfi
If we re-use projectDir for GIT_STRATEGY=none, sometimes the .git directory will be present and sometimes it won't. Sometimes it will have the HEAD relating to the pipeline checked out, and sometimes it will be stale. It becomes unpredictable, and support queries are the result.