MCPcopy
hub / github.com/firecow/gitlab-ci-local / copyOut

Method copyOut

src/job.ts:1527–1548  ·  view source on GitHub ↗
(cmd: string, stateDir: string, type: "artifacts" | "cache", dockerCmdExtras: string[])

Source from the content-addressed store, hash-verified

1525 }
1526
1527 private async copyOut (cmd: string, stateDir: string, type: "artifacts" | "cache", dockerCmdExtras: string[]) {
1528 const safeJobName = this.safeJobName;
1529 const buildVolumeName = this.buildVolumeName;
1530 const cwd = this.argv.cwd;
1531 const helperImageName = this.argv.helperImage;
1532
1533 await fs.mkdirp(`${cwd}/${stateDir}/${type}`);
1534
1535 if (this.imageName(this._variables)) {
1536 const cmdWithWritablePerms = `${cmd}\nchmod -R u+w /${type} 2>/dev/null || true`;
1537 // eslint-disable-next-line @stylistic/quotes
1538 const escapedCmd = cmdWithWritablePerms.replaceAll('"', String.raw`\"`);
1539 const {stdout: containerId} = await Utils.bash(`${this.argv.containerExecutable} create -i ${dockerCmdExtras.join(" ")} -v ${buildVolumeName}:${this.ciProjectDir} -w ${this.ciProjectDir} ${helperImageName} bash -c "${escapedCmd}"`, cwd);
1540 this._containersToClean.push(containerId);
1541 await Utils.spawn([this.argv.containerExecutable, "start", containerId, "--attach"]);
1542 await Utils.spawn([this.argv.containerExecutable, "cp", `${containerId}:/${type}/.`, `${stateDir}/${type}/.`], cwd);
1543 } else if (this.argv.shellIsolation) {
1544 await Utils.bash(`bash -eo pipefail -c "${cmd}"`, `${cwd}/${stateDir}/builds/${safeJobName}`);
1545 } else if (!this.argv.shellIsolation) {
1546 await Utils.bash(`bash -eo pipefail -c "${cmd}"`, `${cwd}`);
1547 }
1548 }
1549
1550 private refreshLongRunningSilentTimeout (writeStreams: WriteStreams) {
1551 clearTimeout(this._longRunningSilentTimeout);

Callers 2

copyCacheOutMethod · 0.95
copyArtifactsOutMethod · 0.95

Calls 3

imageNameMethod · 0.95
bashMethod · 0.80
spawnMethod · 0.80

Tested by

no test coverage detected