()
| 655 | } |
| 656 | |
| 657 | async start (): Promise<void> { |
| 658 | if (this.trigger) { |
| 659 | await this.startTriggerPipeline(); |
| 660 | this._prescriptsExitCode = 0; // NOTE: so that `this.finished` will implicitly be set to true |
| 661 | return; |
| 662 | } |
| 663 | |
| 664 | this._running = true; |
| 665 | |
| 666 | const argv = this.argv; |
| 667 | this._startTime = process.hrtime(); |
| 668 | this._variables["CI_JOB_STARTED_AT"] = new Date().toISOString().split(".")[0] + "Z"; |
| 669 | const writeStreams = this.writeStreams; |
| 670 | this._dotenvVariables = await this.initProducerReportsDotenvVariables(writeStreams, Utils.expandVariables(this._variables)); |
| 671 | const expanded = Utils.unscape$$Variables(Utils.expandVariables({...this._variables, ...this._dotenvVariables})); |
| 672 | const imageName = this.imageName(expanded); |
| 673 | const imagePlatform = this.imagePlatform(expanded); |
| 674 | const helperImageName = argv.helperImage; |
| 675 | const safeJobName = this.safeJobName; |
| 676 | |
| 677 | const outputLogFilePath = `${argv.cwd}/${argv.stateDir}/output/${safeJobName}.log`; |
| 678 | await fs.ensureFile(outputLogFilePath); |
| 679 | await fs.truncate(outputLogFilePath); |
| 680 | |
| 681 | if (!this.interactive) { |
| 682 | writeStreams.stdout(chalk`${this.formattedJobName} {magentaBright starting} ${imageName ?? "shell"} ({yellow ${this.stage}})\n`); |
| 683 | } |
| 684 | |
| 685 | if (imageName) { |
| 686 | await this.pullImage(writeStreams, imageName, imagePlatform); |
| 687 | |
| 688 | const buildVolumeName = this.buildVolumeName; |
| 689 | const tmpVolumeName = this.tmpVolumeName; |
| 690 | const fileVariablesDir = this.fileVariablesDir; |
| 691 | |
| 692 | this._containerVolumeNames.push(buildVolumeName, tmpVolumeName); |
| 693 | await Promise.all([ |
| 694 | Utils.spawn([this.argv.containerExecutable, "volume", "create", `${buildVolumeName}`], argv.cwd), |
| 695 | Utils.spawn([this.argv.containerExecutable, "volume", "create", `${tmpVolumeName}`], argv.cwd), |
| 696 | ]); |
| 697 | |
| 698 | const time = process.hrtime(); |
| 699 | this.refreshLongRunningSilentTimeout(writeStreams); |
| 700 | |
| 701 | let chownOpt = "0:0"; |
| 702 | let chmodOpt = "a+rw"; |
| 703 | if (!this.argv.umask) { |
| 704 | const {stdout} = await Utils.spawn([this.argv.containerExecutable, "run", "--rm", "--entrypoint", "sh", imageName, "-c", "echo \"$(id -u):$(id -g)\""]); |
| 705 | chownOpt = stdout; |
| 706 | if (chownOpt == "0:0") { |
| 707 | chmodOpt = "g-w"; |
| 708 | } |
| 709 | } |
| 710 | if (helperImageName) { |
| 711 | await this.pullImage(writeStreams, helperImageName); |
| 712 | } |
| 713 | |
| 714 | const helperContainerArgs = [ |
no test coverage detected