@@ -1512,7 +1512,14 @@ describe('build plugin test', () => {
1512
1512
id : publishJobId ,
1513
1513
pipelineId,
1514
1514
state : 'ENABLED' ,
1515
- parsePRJobName : sinon . stub ( ) . returns ( 'publish' )
1515
+ parsePRJobName : sinon . stub ( ) . returns ( 'publish' ) ,
1516
+ permutations : [
1517
+ {
1518
+ settings : {
1519
+ email : 'foo@bar.com'
1520
+ }
1521
+ }
1522
+ ]
1516
1523
} ;
1517
1524
1518
1525
beforeEach ( ( ) => {
@@ -2332,12 +2339,26 @@ describe('build plugin test', () => {
2332
2339
id : 2 ,
2333
2340
pipelineId,
2334
2341
state : 'ENABLED' ,
2335
- parsePRJobName : sinon . stub ( ) . returns ( 'b' )
2342
+ parsePRJobName : sinon . stub ( ) . returns ( 'b' ) ,
2343
+ permutations : [
2344
+ {
2345
+ settings : {
2346
+ email : 'foo@bar.com'
2347
+ }
2348
+ }
2349
+ ]
2336
2350
} ;
2337
2351
const jobC = {
2338
2352
...jobB ,
2339
2353
id : 3 ,
2340
- parsePRJobName : sinon . stub ( ) . returns ( 'c' )
2354
+ parsePRJobName : sinon . stub ( ) . returns ( 'c' ) ,
2355
+ permutations : [
2356
+ {
2357
+ settings : {
2358
+ email : 'foo@bar.com'
2359
+ }
2360
+ }
2361
+ ]
2341
2362
} ;
2342
2363
let buildMocks ;
2343
2364
let jobBconfig ;
@@ -2787,7 +2808,14 @@ describe('build plugin test', () => {
2787
2808
id : 2 ,
2788
2809
pipelineId,
2789
2810
state : 'ENABLED' ,
2790
- parsePRJobName : sinon . stub ( ) . returns ( 'b' )
2811
+ parsePRJobName : sinon . stub ( ) . returns ( 'b' ) ,
2812
+ permutations : [
2813
+ {
2814
+ settings : {
2815
+ email : 'foo@bar.com'
2816
+ }
2817
+ }
2818
+ ]
2791
2819
} ;
2792
2820
const jobC = {
2793
2821
...jobB ,
@@ -2804,6 +2832,10 @@ describe('build plugin test', () => {
2804
2832
) ,
2805
2833
parsePRJobName : sinon . stub ( ) . returns ( 'c' )
2806
2834
} ;
2835
+ const jobD = {
2836
+ ...jobB ,
2837
+ id : 4
2838
+ } ;
2807
2839
const externalEventBuilds = [
2808
2840
{
2809
2841
id : 555 ,
@@ -2887,10 +2919,12 @@ describe('build plugin test', () => {
2887
2919
eventFactoryMock . get . withArgs ( 8888 ) . resolves ( parentEventMock ) ;
2888
2920
jobFactoryMock . get . withArgs ( jobB . id ) . resolves ( jobB ) ;
2889
2921
jobFactoryMock . get . withArgs ( jobC . id ) . resolves ( jobC ) ;
2922
+ jobFactoryMock . get . withArgs ( jobD . id ) . resolves ( jobD ) ;
2890
2923
jobFactoryMock . get . withArgs ( 6 ) . resolves ( jobC ) ;
2891
2924
jobFactoryMock . get . withArgs ( 3 ) . resolves ( jobC ) ;
2892
2925
jobFactoryMock . get . withArgs ( { pipelineId, name : 'b' } ) . resolves ( jobB ) ;
2893
2926
jobFactoryMock . get . withArgs ( { pipelineId, name : 'c' } ) . resolves ( jobC ) ;
2927
+ jobFactoryMock . get . withArgs ( { pipelineId, name : 'd' } ) . resolves ( jobD ) ;
2894
2928
jobFactoryMock . list . resolves ( [ { id : 5555 } ] ) ;
2895
2929
jobMock . name = 'a' ;
2896
2930
buildMock . eventId = '8888' ;
@@ -2989,6 +3023,24 @@ describe('build plugin test', () => {
2989
3023
} ) ;
2990
3024
} ) ;
2991
3025
it ( 'triggers next job as external when user used external syntax for same pipeline' , ( ) => {
3026
+ const pipeline2JobB = {
3027
+ id : 2 ,
3028
+ pipelineId : 123 ,
3029
+ name : 'b' ,
3030
+ state : 'ENABLED' ,
3031
+ parsePRJobName : sinon . stub ( ) . returns ( 'b' ) ,
3032
+ permutations : [
3033
+ {
3034
+ settings : {
3035
+ email : 'foo@bar.com'
3036
+ }
3037
+ }
3038
+ ]
3039
+ } ;
3040
+
3041
+ jobFactoryMock . get . withArgs ( { pipelineId : '123' , name : 'b' } ) . resolves ( pipeline2JobB ) ;
3042
+ jobFactoryMock . get . withArgs ( pipeline2JobB . id ) . resolves ( pipeline2JobB ) ;
3043
+
2992
3044
const expectedEventArgs = {
2993
3045
pipelineId : '123' ,
2994
3046
startFrom : '~sd@123:a' ,
@@ -3038,6 +3090,24 @@ describe('build plugin test', () => {
3038
3090
} ) ;
3039
3091
3040
3092
it ( 'triggers next next job when next job is external' , ( ) => {
3093
+ const pipeline2JobA = {
3094
+ id : 2 ,
3095
+ pipelineId : 2 ,
3096
+ name : 'a' ,
3097
+ state : 'ENABLED' ,
3098
+ parsePRJobName : sinon . stub ( ) . returns ( 'a' ) ,
3099
+ permutations : [
3100
+ {
3101
+ settings : {
3102
+ email : 'foo@bar.com'
3103
+ }
3104
+ }
3105
+ ]
3106
+ } ;
3107
+
3108
+ jobFactoryMock . get . withArgs ( { pipelineId : '2' , name : 'a' } ) . resolves ( pipeline2JobA ) ;
3109
+ jobFactoryMock . get . withArgs ( pipeline2JobA . id ) . resolves ( pipeline2JobA ) ;
3110
+
3041
3111
const expectedEventArgs = {
3042
3112
pipelineId : '2' ,
3043
3113
startFrom : '~sd@123:a' ,
@@ -3536,6 +3606,24 @@ describe('build plugin test', () => {
3536
3606
it ( 'triggers if all jobs in external join are done and updates join job' , ( ) => {
3537
3607
// re-entry case
3538
3608
// join-job exist
3609
+ const pipeline2JobC = {
3610
+ id : 3 ,
3611
+ pipelineId : 2 ,
3612
+ name : 'c' ,
3613
+ state : 'ENABLED' ,
3614
+ parsePRJobName : sinon . stub ( ) . returns ( 'c' ) ,
3615
+ permutations : [
3616
+ {
3617
+ settings : {
3618
+ email : 'foo@bar.com'
3619
+ }
3620
+ }
3621
+ ]
3622
+ } ;
3623
+
3624
+ jobFactoryMock . get . withArgs ( { pipelineId : '2' , name : 'c' } ) . resolves ( pipeline2JobC ) ;
3625
+ jobFactoryMock . get . withArgs ( pipeline2JobC . id ) . resolves ( pipeline2JobC ) ;
3626
+
3539
3627
eventMock . workflowGraph = {
3540
3628
nodes : [
3541
3629
{ name : '~pr' } ,
@@ -3669,6 +3757,24 @@ describe('build plugin test', () => {
3669
3757
// ~sd@2:a -> a -> sd@2:c
3670
3758
// If user is at `a`, it should trigger `sd@2:c`
3671
3759
// No join-job, so create
3760
+ const pipeline2JobC = {
3761
+ id : 6 ,
3762
+ pipelineId : 2 ,
3763
+ name : 'c' ,
3764
+ state : 'ENABLED' ,
3765
+ parsePRJobName : sinon . stub ( ) . returns ( 'c' ) ,
3766
+ permutations : [
3767
+ {
3768
+ settings : {
3769
+ email : 'foo@bar.com'
3770
+ }
3771
+ }
3772
+ ]
3773
+ } ;
3774
+
3775
+ jobFactoryMock . get . withArgs ( { pipelineId : '2' , name : 'c' } ) . resolves ( pipeline2JobC ) ;
3776
+ jobFactoryMock . get . withArgs ( pipeline2JobC . id ) . resolves ( pipeline2JobC ) ;
3777
+
3672
3778
eventMock . workflowGraph = {
3673
3779
nodes : [
3674
3780
{ name : '~pr' } ,
@@ -3705,7 +3811,7 @@ describe('build plugin test', () => {
3705
3811
baseBranch : 'master' ,
3706
3812
configPipelineSha : 'abc123' ,
3707
3813
eventId : 8887 ,
3708
- jobId : 3 ,
3814
+ jobId : 6 ,
3709
3815
parentBuildId : [ 12345 ] ,
3710
3816
parentBuilds : {
3711
3817
123 : { eventId : '8888' , jobs : { a : 12345 } } ,
@@ -3787,6 +3893,24 @@ describe('build plugin test', () => {
3787
3893
// ~sd@2:b ------➚
3788
3894
// If user is at `a`, it should trigger `sd@2:c`
3789
3895
// ~sd@123:a is or trigger, so create
3896
+ const pipeline2JobC = {
3897
+ id : 6 ,
3898
+ pipelineId : 2 ,
3899
+ name : 'c' ,
3900
+ state : 'ENABLED' ,
3901
+ parsePRJobName : sinon . stub ( ) . returns ( 'c' ) ,
3902
+ permutations : [
3903
+ {
3904
+ settings : {
3905
+ email : 'foo@bar.com'
3906
+ }
3907
+ }
3908
+ ]
3909
+ } ;
3910
+
3911
+ jobFactoryMock . get . withArgs ( { pipelineId : '2' , name : 'c' } ) . resolves ( pipeline2JobC ) ;
3912
+ jobFactoryMock . get . withArgs ( pipeline2JobC . id ) . resolves ( pipeline2JobC ) ;
3913
+
3790
3914
eventMock . workflowGraph = {
3791
3915
nodes : [
3792
3916
{ name : '~pr' } ,
@@ -3819,11 +3943,11 @@ describe('build plugin test', () => {
3819
3943
parentBuilds,
3820
3944
start : sinon . stub ( ) . resolves ( )
3821
3945
} ) ;
3822
- const jobCConfig = {
3946
+ const pipeline2JobCConfig = {
3823
3947
baseBranch : 'master' ,
3824
3948
configPipelineSha : 'abc123' ,
3825
3949
eventId : 8887 ,
3826
- jobId : 3 ,
3950
+ jobId : 6 ,
3827
3951
parentBuildId : 12345 ,
3828
3952
parentBuilds : {
3829
3953
123 : { eventId : '8888' , jobs : { a : 12345 } } ,
@@ -3844,7 +3968,7 @@ describe('build plugin test', () => {
3844
3968
pr : { } ,
3845
3969
id : 8887 ,
3846
3970
configPipelineSha : 'abc123' ,
3847
- pipelineId : 123 ,
3971
+ pipelineId : 2 ,
3848
3972
baseBranch : 'master' ,
3849
3973
builds : [
3850
3974
{
@@ -3896,11 +4020,45 @@ describe('build plugin test', () => {
3896
4020
assert . notCalled ( eventFactoryMock . create ) ;
3897
4021
assert . calledOnce ( buildFactoryMock . getLatestBuilds ) ;
3898
4022
assert . calledOnce ( buildFactoryMock . create ) ;
3899
- assert . calledWith ( buildFactoryMock . create , jobCConfig ) ;
4023
+ assert . calledWith ( buildFactoryMock . create , pipeline2JobCConfig ) ;
3900
4024
} ) ;
3901
4025
} ) ;
3902
4026
3903
4027
it ( 'starts multiple builds with the existing downstream event' , ( ) => {
4028
+ const pipeline2JobC = {
4029
+ id : 6 ,
4030
+ pipelineId : 2 ,
4031
+ name : 'c' ,
4032
+ state : 'ENABLED' ,
4033
+ parsePRJobName : sinon . stub ( ) . returns ( 'c' ) ,
4034
+ permutations : [
4035
+ {
4036
+ settings : {
4037
+ email : 'foo@bar.com'
4038
+ }
4039
+ }
4040
+ ]
4041
+ } ;
4042
+ const pipeline2JobD = {
4043
+ id : 7 ,
4044
+ pipelineId : 2 ,
4045
+ name : 'd' ,
4046
+ state : 'ENABLED' ,
4047
+ parsePRJobName : sinon . stub ( ) . returns ( 'd' ) ,
4048
+ permutations : [
4049
+ {
4050
+ settings : {
4051
+ email : 'foo@bar.com'
4052
+ }
4053
+ }
4054
+ ]
4055
+ } ;
4056
+
4057
+ jobFactoryMock . get . withArgs ( { pipelineId : '2' , name : 'c' } ) . resolves ( pipeline2JobC ) ;
4058
+ jobFactoryMock . get . withArgs ( pipeline2JobC . id ) . resolves ( pipeline2JobC ) ;
4059
+ jobFactoryMock . get . withArgs ( { pipelineId : '2' , name : 'd' } ) . resolves ( pipeline2JobD ) ;
4060
+ jobFactoryMock . get . withArgs ( pipeline2JobD . id ) . resolves ( pipeline2JobD ) ;
4061
+
3904
4062
eventMock . workflowGraph = {
3905
4063
nodes : [
3906
4064
{ name : '~pr' } ,
@@ -4081,6 +4239,24 @@ describe('build plugin test', () => {
4081
4239
} ) ;
4082
4240
4083
4241
it ( 'creates without starting join job in external join when fork not done' , ( ) => {
4242
+ const pipeline2JobC = {
4243
+ id : 3 ,
4244
+ pipelineId : 2 ,
4245
+ name : 'c' ,
4246
+ state : 'ENABLED' ,
4247
+ parsePRJobName : sinon . stub ( ) . returns ( 'c' ) ,
4248
+ permutations : [
4249
+ {
4250
+ settings : {
4251
+ email : 'foo@bar.com'
4252
+ }
4253
+ }
4254
+ ]
4255
+ } ;
4256
+
4257
+ jobFactoryMock . get . withArgs ( { pipelineId : '2' , name : 'c' } ) . resolves ( pipeline2JobC ) ;
4258
+ jobFactoryMock . get . withArgs ( pipeline2JobC . id ) . resolves ( pipeline2JobC ) ;
4259
+
4084
4260
eventMock . workflowGraph = {
4085
4261
nodes : [
4086
4262
{ name : '~pr' } ,
@@ -4703,6 +4879,24 @@ describe('build plugin test', () => {
4703
4879
// d
4704
4880
//
4705
4881
// If user restarts `123:a`, it should get `2:c`'s parent event status and trigger `c`
4882
+ const pipeline2JobC = {
4883
+ id : 3 ,
4884
+ pipelineId : 2 ,
4885
+ name : 'c' ,
4886
+ state : 'ENABLED' ,
4887
+ parsePRJobName : sinon . stub ( ) . returns ( 'c' ) ,
4888
+ permutations : [
4889
+ {
4890
+ settings : {
4891
+ email : 'foo@bar.com'
4892
+ }
4893
+ }
4894
+ ]
4895
+ } ;
4896
+
4897
+ jobFactoryMock . get . withArgs ( { pipelineId : '2' , name : 'c' } ) . resolves ( pipeline2JobC ) ;
4898
+ jobFactoryMock . get . withArgs ( pipeline2JobC . id ) . resolves ( pipeline2JobC ) ;
4899
+
4706
4900
eventMock . workflowGraph = {
4707
4901
nodes : [
4708
4902
{ name : '~pr' } ,
0 commit comments