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

@@ -11,7 +11,8 @@ export default async function ({
apiUrl,
htmlUrl,
branch,
buildId
buildId,
customPort
}: {
applicationId: string;
workdir: string;
@@ -21,6 +22,7 @@ export default async function ({
htmlUrl: string;
branch: string;
buildId: string;
customPort: number;
}): Promise<string> {
const { default: got } = await import('got')
const url = htmlUrl.replace('https://', '').replace('http://', '');
@@ -54,7 +56,7 @@ export default async function ({
applicationId
});
await asyncExecShell(
`git clone -q -b ${branch} https://x-access-token:${token}@${url}/${repository}.git ${workdir}/ && cd ${workdir} && git submodule update --init --recursive && git lfs pull && cd .. `
`git clone -q -b ${branch} https://x-access-token:${token}@${url}/${repository}.git --config core.sshCommand="ssh -p ${customPort}" ${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', '');

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', '');