Skip to content

Commit c5c2056

Browse files
committed
fix: pass artifact paths to rsync via --files-from temp file
- Collect artifact paths into a temp file using a bash for loop instead of appending them directly as rsync CLI arguments - Use rsync --files-from to read paths from the temp file, avoiding ARG_MAX (~2 MB) exceeded errors with large artifacts - The bash for loop (a shell built-in) correctly expands glob patterns and is not subject to ARG_MAX constraints - Remove the temp file after rsync completes
1 parent fe3304c commit c5c2056

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

src/job.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,16 +1424,18 @@ If you know what you're doing and would like to suppress this warning, use one o
14241424
let time, endTime;
14251425
let cpCmd = "shopt -s globstar nullglob dotglob\n";
14261426
cpCmd += `mkdir -p ${artifactsPath}/${safeJobName}\n`;
1427+
cpCmd += "_gcl_files_tmp=\\$(mktemp)\n";
1428+
for (const artifactPath of this.artifacts?.paths ?? []) {
1429+
const expandedPath = Utils.expandText(artifactPath, expanded).replace(`${expanded.CI_PROJECT_DIR}/`, "");
1430+
cpCmd += `for _gcl_f in ./${expandedPath}; do printf '%s\\n' \\"\\$_gcl_f\\" >> \\$_gcl_files_tmp; done\n`;
1431+
}
14271432
cpCmd += "rsync --exclude '.gitlab-ci-local/**' -Ra ";
14281433
for (const artifactExcludePath of this.artifacts?.exclude ?? []) {
14291434
const expandedPath = Utils.expandText(artifactExcludePath, expanded).replace(`${expanded.CI_PROJECT_DIR}/`, "");
14301435
cpCmd += `--exclude '${expandedPath}' `;
14311436
}
1432-
for (const artifactPath of this.artifacts?.paths ?? []) {
1433-
const expandedPath = Utils.expandText(artifactPath, expanded).replace(`${expanded.CI_PROJECT_DIR}/`, "");
1434-
cpCmd += `./${expandedPath} `;
1435-
}
1436-
cpCmd += `${artifactsPath}/${safeJobName}/. || true\n`;
1437+
cpCmd += `--files-from=\\$_gcl_files_tmp . ${artifactsPath}/${safeJobName}/. || true\n`;
1438+
cpCmd += "rm -f \\$_gcl_files_tmp\n";
14371439
const reportDotenv = Utils.expandText(this.artifacts.reports?.dotenv ?? null, expanded);
14381440
const reportDotenvs: string[] | null = (typeof reportDotenv === "string") ? // normalize to string[] for easier handling
14391441
[reportDotenv] :

0 commit comments

Comments
 (0)