File tree 4 files changed +25
-2
lines changed
4 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -301,7 +301,7 @@ export class Job {
301
301
process . stdout . write ( `${ this . getJobNameString ( ) } ${ magentaBright ( 'pulled' ) } in ${ magenta ( prettyHrtime ( endTime ) ) } \n` ) ;
302
302
303
303
let dockerCmd = `` ;
304
- dockerCmd += `docker run -u 0:0 -d -i -w //builds/ ${ this . image } ` ;
304
+ dockerCmd += `docker create -u 0:0 -i ${ this . image } ` ;
305
305
dockerCmd += `sh -c "\n`
306
306
dockerCmd += `if [ -x /usr/local/bin/bash ]; then\n`
307
307
dockerCmd += `\texec /usr/local/bin/bash \n` ;
@@ -331,7 +331,7 @@ export class Job {
331
331
process . stdout . write ( `${ this . getJobNameString ( ) } ${ magentaBright ( 'copied' ) } in ${ magenta ( prettyHrtime ( endTime ) ) } \n` ) ;
332
332
}
333
333
334
- const cp = childProcess . spawn ( this . containerId ? `docker attach ${ this . containerId } ` : `bash -e` , {
334
+ const cp = childProcess . spawn ( this . containerId ? `docker start -- attach -i ${ this . containerId } ` : `bash -e` , {
335
335
shell : 'bash' ,
336
336
stdio : [ 'pipe' , 'pipe' , 'pipe' ] ,
337
337
cwd : this . cwd ,
@@ -340,6 +340,7 @@ export class Job {
340
340
cp . stdin . write ( `set -eo pipefail\n` ) ;
341
341
342
342
if ( this . image ) {
343
+ cp . stdin . write ( `cd /builds/\n` ) ;
343
344
cp . stdin . write ( `chown root:root -R .\n` ) ;
344
345
cp . stdin . write ( `chmod a+w -R .\n` ) ;
345
346
}
Original file line number Diff line number Diff line change @@ -100,6 +100,20 @@ test('image <test-job>', async () => {
100
100
expect ( mockProcessStdout ) . toHaveBeenCalledWith ( "Test something\n" ) ;
101
101
} ) ;
102
102
103
+ test ( 'image <test-entrypoint>' , async ( ) => {
104
+ await defaultCmd . handler ( {
105
+ cwd : 'tests/test-cases/image' ,
106
+ job : 'test-entrypoint'
107
+ } ) ;
108
+
109
+ expect ( mockProcessStdout ) . toHaveBeenCalledWith ( "/\n" ) ;
110
+ expect ( mockProcessStdout ) . toHaveBeenCalledWith ( "Hello from 'firecow/gitlab-ci-local-test-image' image entrypoint\n" ) ;
111
+ expect ( mockProcessStdout ) . toHaveBeenCalledWith ( "/builds\n" ) ;
112
+ expect ( mockProcessStdout ) . toHaveBeenCalledWith ( "Test Entrypoint\n" ) ;
113
+ expect ( mockProcessStdout ) . toHaveBeenCalledWith ( "I'm a test file\n" ) ;
114
+
115
+ } ) ;
116
+
103
117
test ( 'no-script <test-job>' , async ( ) => {
104
118
try {
105
119
await defaultCmd . handler ( {
Original file line number Diff line number Diff line change @@ -5,3 +5,10 @@ test-job:
5
5
image : ${PHP_IMAGE_URL}
6
6
script :
7
7
- echo "Test something"
8
+
9
+ test-entrypoint :
10
+ image : firecow/gitlab-ci-local-test-image
11
+ script :
12
+ - pwd
13
+ - echo "Test Entrypoint"
14
+ - cat test-file.txt
Original file line number Diff line number Diff line change
1
+ I'm a test file
You can’t perform that action at this time.
0 commit comments