@@ -101,19 +101,30 @@ export class Job {
101
101
this . allowFailure = ruleResult . allowFailure ;
102
102
}
103
103
104
- if ( this . interactive && ( this . when !== 'manual' || this . image !== null ) ) {
104
+ if ( this . interactive && ( this . when !== 'manual' || this . imageName !== null ) ) {
105
105
throw new ExitError ( `${ this . getJobNameString ( ) } @Interactive decorator cannot have image: and must be when:manual` ) ;
106
106
}
107
107
}
108
108
109
- get image ( ) : string | null {
110
- let image = this . jobData [ 'image' ]
109
+ get imageName ( ) : string | null {
110
+ const image = this . jobData [ 'image' ] ;
111
111
if ( ! image ) {
112
112
return null ;
113
113
}
114
114
115
- image = Utils . expandText ( image , this . expandedVariables ) ;
116
- return image . includes ( ':' ) ? image : `${ image } :latest`
115
+ const imageName = Utils . expandText ( image . name , this . expandedVariables ) ;
116
+ return imageName . includes ( ':' ) ? imageName : `${ imageName } :latest` ;
117
+ }
118
+
119
+ get imageEntrypoint ( ) : string [ ] | null {
120
+ const image = this . jobData [ 'image' ] ;
121
+ if ( ! image ) {
122
+ return null ;
123
+ }
124
+ if ( typeof image . entrypoint !== 'object' ) {
125
+ throw new ExitError ( `image:entrypoint must be an array` ) ;
126
+ }
127
+ return image . entrypoint ;
117
128
}
118
129
119
130
get stage ( ) : string {
@@ -164,7 +175,7 @@ export class Job {
164
175
await fs . truncate ( this . getOutputFilesPath ( ) ) ;
165
176
if ( ! this . interactive ) {
166
177
const jobNameStr = this . getJobNameString ( ) ;
167
- process . stdout . write ( `${ jobNameStr } ${ magentaBright ( "starting" ) } ${ this . image ?? "shell" } (${ yellow ( this . stage ) } )\n` ) ;
178
+ process . stdout . write ( `${ jobNameStr } ${ magentaBright ( "starting" ) } ${ this . imageName ?? "shell" } (${ yellow ( this . stage ) } )\n` ) ;
168
179
}
169
180
170
181
const prescripts = this . beforeScripts . concat ( this . scripts ) ;
@@ -294,14 +305,14 @@ export class Job {
294
305
} ) ;
295
306
}
296
307
297
- if ( this . image ) {
308
+ if ( this . imageName ) {
298
309
time = process . hrtime ( ) ;
299
- process . stdout . write ( `${ jobNameStr } ${ magentaBright ( 'pulling' ) } ${ this . image } \n` ) ;
310
+ process . stdout . write ( `${ jobNameStr } ${ magentaBright ( 'pulling' ) } ${ this . imageName } \n` ) ;
300
311
let pullCmd = `` ;
301
- pullCmd += `docker image ls --format '{{.Repository}}:{{.Tag}}' | grep -E '^${ this . image } $'\n`
312
+ pullCmd += `docker image ls --format '{{.Repository}}:{{.Tag}}' | grep -E '^${ this . imageName } $'\n`
302
313
pullCmd += `if [ "$?" -ne 0 ]; then\n`
303
- pullCmd += `\techo "Pulling ${ this . image } "\n`
304
- pullCmd += `\tdocker pull ${ this . image } \n`
314
+ pullCmd += `\techo "Pulling ${ this . imageName } "\n`
315
+ pullCmd += `\tdocker pull ${ this . imageName } \n`
305
316
pullCmd += `fi\n`
306
317
await Utils . spawn ( pullCmd , this . cwd ) ;
307
318
endTime = process . hrtime ( time ) ;
@@ -314,11 +325,17 @@ export class Job {
314
325
dockerCmd += `docker create -u 0:0 -i ` ;
315
326
}
316
327
328
+ if ( this . imageEntrypoint ) {
329
+ this . imageEntrypoint . forEach ( ( e ) => {
330
+ dockerCmd += `--entrypoint "${ e } " `
331
+ } ) ;
332
+ }
333
+
317
334
for ( const [ key , value ] of Object . entries ( this . expandedVariables ) ) {
318
335
dockerCmd += `-e ${ key } ="${ String ( value ) . trim ( ) } " `
319
336
}
320
337
321
- dockerCmd += `${ this . image } sh -c "\n`
338
+ dockerCmd += `${ this . imageName } sh -c "\n`
322
339
dockerCmd += `if [ -x /usr/local/bin/bash ]; then\n`
323
340
dockerCmd += `\texec /usr/local/bin/bash \n` ;
324
341
dockerCmd += `elif [ -x /usr/bin/bash ]; then\n` ;
@@ -356,7 +373,7 @@ export class Job {
356
373
357
374
cp . stdin . write ( `set -eo pipefail\n` ) ;
358
375
359
- if ( this . image ) {
376
+ if ( this . imageName ) {
360
377
cp . stdin . write ( `cd /builds/\n` ) ;
361
378
cp . stdin . write ( `chown root:root -R .\n` ) ;
362
379
cp . stdin . write ( `chmod a+w -R .\n` ) ;
@@ -402,7 +419,7 @@ export class Job {
402
419
cp . on ( "error" , ( err ) => reject ( err ) ) ;
403
420
} ) ;
404
421
405
- if ( this . image ) {
422
+ if ( this . imageName ) {
406
423
for ( const artifactPath of this . artifacts . paths ) {
407
424
const expandedPath = Utils . expandText ( artifactPath , this . expandedVariables ) . replace ( / \/ $ / , '' ) ;
408
425
0 commit comments