MCPcopy Index your code
hub / github.com/Dokploy/dokploy / cloneGitlabRepository

Function cloneGitlabRepository

packages/server/src/utils/providers/gitlab.ts:116–157  ·  view source on GitHub ↗
({
	type = "application",
	...entity
}: CloneGitlabRepository)

Source from the content-addressed store, hash-verified

114}
115
116export const cloneGitlabRepository = async ({
117 type = "application",
118 ...entity
119}: CloneGitlabRepository) => {
120 let command = "set -e;";
121 const {
122 appName,
123 gitlabBranch,
124 gitlabId,
125 gitlabPathNamespace,
126 enableSubmodules,
127 serverId,
128 outputPathOverride,
129 } = entity;
130 const { COMPOSE_PATH, APPLICATIONS_PATH } = paths(!!serverId);
131
132 if (!gitlabId) {
133 command += `echo "Error: ❌ Gitlab Provider not found"; exit 1;`;
134 return command;
135 }
136
137 await refreshGitlabToken(gitlabId);
138 const gitlab = await findGitlabById(gitlabId);
139
140 const requirements = getErrorCloneRequirements(entity);
141
142 // Check if requirements are met
143 if (requirements.length > 0) {
144 command += `echo "❌ [ERROR] GitLab Repository configuration failed for application: ${appName}"; echo "Reasons:"; echo "${requirements.join("\n")}"; exit 1;`;
145 return command;
146 }
147
148 const basePath = type === "compose" ? COMPOSE_PATH : APPLICATIONS_PATH;
149 const outputPath = outputPathOverride ?? join(basePath, appName, "code");
150 command += `rm -rf ${outputPath};`;
151 command += `mkdir -p ${outputPath};`;
152 const repoClone = getGitlabRepoClone(gitlab, gitlabPathNamespace);
153 const cloneUrl = getGitlabCloneUrl(gitlab, repoClone);
154 command += `echo "Cloning Repo ${repoClone} to ${outputPath}: ✅";`;
155 command += `git clone --branch ${gitlabBranch} --depth 1 ${enableSubmodules ? "--recurse-submodules" : ""} ${cloneUrl} ${outputPath} --progress;`;
156 return command;
157};
158
159export const getGitlabRepositories = async (gitlabId?: string) => {
160 if (!gitlabId) {

Callers 4

cloneComposeFunction · 0.90
ensurePatchRepoFunction · 0.90
deployComposeFunction · 0.90
deployApplicationFunction · 0.90

Calls 6

pathsFunction · 0.90
findGitlabByIdFunction · 0.90
refreshGitlabTokenFunction · 0.85
getGitlabRepoCloneFunction · 0.85
getGitlabCloneUrlFunction · 0.85

Tested by

no test coverage detected