Closed
Description
Is your feature request related to a problem? Please describe.
I have a private gitlab-instance that has no ssh-access enabled. I have to clone/push/etc via https.
When using includes in my gitlab-ci.yaml
, gitlab-ci-local tries to download these includes. The function downloadIncludeProjectFile
uses git archive
under the hood which does not work with https but only with ssh.
Describe the solution you'd like
I'd like to use includes with my instance that has no ssh enabled.
Describe alternatives you've considered
Additional context
I thought about doing it with curl or wget via the gitlab API like this:
static async downloadIncludeProjectFile (cwd: string, stateDir: string, project: string, ref: string, file: string, gitData: GitData, fetchIncludes: boolean): Promise<void> {
const remote = gitData.remote;
const normalizedFile = file.replace(/^\/+/, "");
try {
const target = `${stateDir}/includes/${remote.host}/${project}/${ref}/`;
if (await fs.pathExists(`${cwd}/${target}/${normalizedFile}`) && !fetchIncludes) return;
await fs.mkdirp(`${cwd}/${target}`);
await Utils.bash(`git archive --remote=ssh://git@${remote.host}:${remote.port}/${project}.git ${ref} ${normalizedFile} | tar -f - -xC ${target}`, cwd);
} catch (e) {
try {
const target = `${stateDir}/includes/${remote.host}/${project}/${ref}/`;
if (await fs.pathExists(`${cwd}/${target}/${normalizedFile}`) && !fetchIncludes) return;
await fs.mkdirp(`${cwd}/${target}`);
await Utils.bash(`curl --header "Private-Token: ${token}" -O ${target}/${normalizedFile} https://${fomain}/api/v4/projects/${project}/repository/files/${normalizedFile}?ref=${ref}`, cwd);
} catch (e) {
throw new ExitError(`Project include could not be fetched { project: ${project}, ref: ${ref}, file: ${normalizedFile} }`)
;
}
}
}
Or maybe with axios? However I'm not proficient with javascript to include a working solution.