How can I use git archive ... as part of a job’s before_script?
Here are my failed attempts so far:
$ git archive --format=tar.gz HEAD reports | (cd $MY_BUILD_PATH && tar -zxf -)
fatal: not a git repository (or any parent up to mount point /builds)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
$ git archive --format=tar.gz --remote git@gitlab.host.net/user/bi-eha.git HEAD reports | (cd $MY_BUILD_PATH && tar -zxf -)
Host key verification failed.
fatal: the remote end hung up unexpectedly
$ git archive --format=tar.gz --remote https://gitlab.host.net/user/bi-eha.git HEAD reports | (cd $MY_BUILD_PATH && tar -zxf -)
fatal: operation not supported by protocol
I only need a specific subdirectory and below to perform a specific job. git archive would seem to be the best for moving the needed files to a build directory.
As you can see from my posts here, I already know how to avoid moving LFS files.
My original question still stands. How can git archive be used for a GitLab CI job?
But that’s not how git archive works! It needs a local repository–which you have suppressed by using GIT_STRATEGY: none. Your second format accesses an archive in the remote repository, it doesn’t create an archive from the repository.
No! Not “exactly”. You can absolutely use git archive but that command requires you to already have a local repository. You’ve told gitlab not to clone a local repo! The command you’ve shown for a remote repo doesn’t do want you’re asking, regardless of whether you’re using gitlab
I won’t be amazed. git archive against a remote repo requires an archive in the repo. You could still do that. Your example is not trying to access an archive.
And besides which, their CI is only insecure because they published the key for you to see how it’s done. You would use it exactly the same way–and just not publish the key for anybody else to use
I honestly don’t know what you are addressing now. The repo and CI jobs speak for themselves. Have you looked at the contents of the repo and the log of the CI jobs? Perhaps you are answering an unasked question?
… and yet my example repo has no archive in the repo … and the CI job moves an archive to the build directory.
… I generated and installed the public/private keys here.