feat: custom port for git instances

This commit is contained in:
Andras Bacsai
2022-07-12 11:01:48 +02:00
parent 9b47de71fc
commit 5a7edcb762
8 changed files with 137 additions and 29 deletions

View File

@@ -9,7 +9,8 @@ export default async function ({
repository,
branch,
buildId,
privateSshKey
privateSshKey,
customPort
}: {
applicationId: string;
workdir: string;
@@ -19,6 +20,7 @@ export default async function ({
buildId: string;
repodir: string;
privateSshKey: string;
customPort: number;
}): Promise<string> {
const url = htmlUrl.replace('https://', '').replace('http://', '').replace(/\/$/, '');
await saveBuildLog({ line: 'GitLab importer started.', buildId, applicationId });
@@ -32,7 +34,7 @@ export default async function ({
});
await asyncExecShell(
`git clone -q -b ${branch} git@${url}:${repository}.git --config core.sshCommand="ssh -q -i ${repodir}id.rsa -o StrictHostKeyChecking=no" ${workdir}/ && cd ${workdir}/ && git submodule update --init --recursive && git lfs pull && cd .. `
`git clone -q -b ${branch} git@${url}:${repository}.git --config core.sshCommand="ssh -p ${customPort} -q -i ${repodir}id.rsa -o StrictHostKeyChecking=no" ${workdir}/ && cd ${workdir}/ && git submodule update --init --recursive && git lfs pull && cd .. `
);
const { stdout: commit } = await asyncExecShell(`cd ${workdir}/ && git rev-parse HEAD`);
return commit.replace('\n', '');