@@ -18,8 +18,8 @@ import {Parser} from "./parser.js";
1818import { resolveIncludeLocal , validateIncludeLocal } from "./parser-includes.js" ;
1919import { globbySync } from "globby" ;
2020import terminalLink from "terminal-link" ;
21- import * as crypto from "crypto" ;
22- import * as path from "path" ;
21+ import * as crypto from "node: crypto" ;
22+ import * as path from "node: path" ;
2323
2424const GCL_SHELL_PROMPT_PLACEHOLDER = "<gclShellPromptPlaceholder>" ;
2525interface JobOptions {
@@ -163,7 +163,13 @@ export class Job {
163163 this . allowFailure = jobData . allow_failure ?? false ;
164164 this . dependencies = jobData . dependencies || null ;
165165 this . rules = jobData . rules || null ;
166- this . environment = typeof jobData . environment === "string" ? { name : jobData . environment } : ( jobData . environment ? { ...jobData . environment } : jobData . environment ) ;
166+ if ( typeof jobData . environment === "string" ) {
167+ this . environment = { name : jobData . environment , url : null , deployment_tier : null , action : null } ;
168+ } else if ( jobData . environment ) {
169+ this . environment = { ...jobData . environment } ;
170+ } else {
171+ this . environment = jobData . environment ;
172+ }
167173
168174 const matrixVariables = opt . matrixVariables ?? { } ;
169175 const fileVariables = Utils . findEnvMatchedVariables ( variablesFromFiles , this . fileVariablesDir ) ;
@@ -236,7 +242,7 @@ export class Job {
236242 }
237243 // Set GCL_PROJECT_DIR_ON_HOST if docker image
238244 if ( this . imageName ( this . _variables ) ) {
239- this . _variables = { ...this . _variables , ... { GCL_PROJECT_DIR_ON_HOST : cwd } } ;
245+ this . _variables = { ...this . _variables , GCL_PROJECT_DIR_ON_HOST : cwd } ;
240246 }
241247
242248 assert ( this . scripts || this . trigger , chalk `{blueBright ${ this . name } } must have script specified` ) ;
@@ -327,7 +333,7 @@ If you know what you're doing and would like to suppress this warning, use one o
327333 predefinedVariables [ "CI_PIPELINE_ID" ] = `${ this . pipelineIid + 1000 } ` ;
328334 predefinedVariables [ "CI_PIPELINE_IID" ] = `${ this . pipelineIid } ` ;
329335 predefinedVariables [ "CI_JOB_NAME" ] = `${ this . name } ` ;
330- predefinedVariables [ "CI_JOB_NAME_SLUG" ] = `${ this . name . replace ( / [ ^ a - z \d ] + / ig, "-" ) . replace ( / ^ - / , "" ) . slice ( 0 , 63 ) . replace ( / - $ / , "" ) . toLowerCase ( ) } ` ;
336+ predefinedVariables [ "CI_JOB_NAME_SLUG" ] = `${ this . name . replaceAll ( / [ ^ a - z \d ] + / ig, "-" ) . replace ( / ^ - / , "" ) . slice ( 0 , 63 ) . replace ( / - $ / , "" ) . toLowerCase ( ) } ` ;
331337 predefinedVariables [ "CI_JOB_STAGE" ] = `${ this . stage } ` ;
332338 predefinedVariables [ "CI_BUILDS_DIR" ] = ciBuildsDir ;
333339 predefinedVariables [ "CI_PROJECT_DIR" ] = this . ciProjectDir ;
@@ -365,8 +371,8 @@ If you know what you're doing and would like to suppress this warning, use one o
365371 // 1. Lowercase, replace non-alphanumeric with '-', and squeeze repeating '-'
366372 let slug = name
367373 . toLowerCase ( )
368- . replace ( / [ ^ a - z 0 - 9 ] / g, "-" )
369- . replace ( / - + / g, "-" ) ;
374+ . replaceAll ( / [ ^ a - z 0 - 9 ] / g, "-" )
375+ . replaceAll ( / - + / g, "-" ) ;
370376
371377 // 2. Must start with a letter
372378 if ( ! / ^ [ a - z ] / . test ( slug ) ) {
@@ -1029,7 +1035,7 @@ If you know what you're doing and would like to suppress this warning, use one o
10291035
10301036 for ( const [ key , val ] of Object . entries ( expanded ) ) {
10311037 // Replacing `'` with `'\''` to correctly handle single quotes(if `val` contains `'`) in shell commands
1032- dockerCmd += ` -e '${ key } =${ val . toString ( ) . replace ( / ' / g , "'\\''" ) } ' \\\n` ;
1038+ dockerCmd += ` -e '${ key } =${ val . toString ( ) . replaceAll ( "'" , String . raw `'\''` ) } ' \\\n` ;
10331039 }
10341040
10351041 if ( this . imageEntrypoint ) {
@@ -1588,7 +1594,7 @@ If you know what you're doing and would like to suppress this warning, use one o
15881594
15891595 for ( const [ key , val ] of Object . entries ( expanded ) ) {
15901596 // Replacing `'` with `'\''` to correctly handle single quotes(if `val` contains `'`) in shell commands
1591- dockerCmd += ` -e '${ key } =${ val . toString ( ) . replace ( / ' / g , "'\\''" ) } ' \\\n` ;
1597+ dockerCmd += ` -e '${ key } =${ val . toString ( ) . replaceAll ( "'" , String . raw `'\''` ) } ' \\\n` ;
15921598 }
15931599
15941600 const serviceEntrypoint = service . entrypoint ;
@@ -1671,11 +1677,12 @@ If you know what you're doing and would like to suppress this warning, use one o
16711677 } ) ;
16721678 } finally {
16731679 // Kill all wait-for-it containers, when one have been successful
1674- await Promise . allSettled ( Object . keys ( imageInspect [ 0 ] . Config . ExposedPorts ) . map ( ( port ) => {
1675- if ( ! port . endsWith ( "/tcp" ) ) return ;
1676- const portNum = parseInt ( port . replace ( "/tcp" , "" ) ) ;
1677- return Utils . spawn ( [ this . argv . containerExecutable , "rm" , "-vf" , `gcl-wait-for-it-${ this . jobId } -${ serviceIndex } -${ portNum } ` ] ) ;
1678- } ) ) ;
1680+ await Promise . allSettled ( Object . keys ( imageInspect [ 0 ] . Config . ExposedPorts )
1681+ . filter ( ( port ) => port . endsWith ( "/tcp" ) )
1682+ . map ( ( port ) => {
1683+ const portNum = Number . parseInt ( port . replace ( "/tcp" , "" ) ) ;
1684+ return Utils . spawn ( [ this . argv . containerExecutable , "rm" , "-vf" , `gcl-wait-for-it-${ this . jobId } -${ serviceIndex } -${ portNum } ` ] ) ;
1685+ } ) ) ;
16791686 }
16801687 }
16811688
0 commit comments