File tree 2 files changed +36
-0
lines changed
2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change 1
1
import * as c from "ansi-colors" ;
2
+ import * as deepExtend from "deep-extend" ;
2
3
import * as prettyHrtime from "pretty-hrtime" ;
3
4
import * as shelljs from "shelljs" ;
4
5
@@ -27,6 +28,23 @@ export class Job {
27
28
this . cwd = cwd ;
28
29
this . globals = globals ;
29
30
31
+ // Parse extends
32
+ if ( jobData . extends ) {
33
+ const extendList = [ ] . concat ( jobData . extends ) ;
34
+ const deepExtendList : any [ ] = [ ] ;
35
+ extendList . forEach ( ( parentJobName ) => {
36
+ if ( ! globals [ parentJobName ] ) {
37
+ console . error ( `${ c . red ( `'${ parentJobName } ' could not be found` ) } ` ) ;
38
+ process . exit ( 1 ) ;
39
+ }
40
+ deepExtendList . push ( globals [ parentJobName ] ) ;
41
+ } ) ;
42
+
43
+ deepExtendList . push ( jobData ) ;
44
+ // tslint:disable-next-line:no-parameter-reassignment
45
+ jobData = deepExtend . apply ( this , deepExtendList ) ;
46
+ }
47
+
30
48
this . stage = jobData . stage || ".pre" ;
31
49
this . scripts = [ ] . concat ( jobData . script || [ ] ) ;
32
50
Original file line number Diff line number Diff line change @@ -6,9 +6,27 @@ include:
6
6
.defaultTags : &tags
7
7
tags : [some_runner_tag]
8
8
9
+ .parent0 :
10
+ << : *tags
11
+ stage : prepare
12
+ before_script : [echo "I'm from parents0 (before_script)"]
13
+ script : [echo "I'm from parents0 (script)"]
14
+ after_script : [echo "I'm from parents0 (after_script)"]
15
+
16
+ .parent1 :
17
+ stage : build
18
+ before_script : [echo "I'm from parents1 (before_script)"]
19
+ script : [echo "I'm from parents1 (script)"]
20
+ after_script : [echo "I'm from parents1 (after_script)"]
21
+
9
22
variables :
10
23
PROJECT_NAME : test-yml-spec-project
11
24
25
+ extending :
26
+ extends : [.parent0, .parent1]
27
+ script :
28
+ - echo "I'm from extending (script)"
29
+
12
30
echo_project_name :
13
31
<< : *tags
14
32
stage : startup
You can’t perform that action at this time.
0 commit comments