File tree Expand file tree Collapse file tree 2 files changed +53
-1
lines changed Expand file tree Collapse file tree 2 files changed +53
-1
lines changed Original file line number Diff line number Diff line change
1
+ const { parseSlugFromRemoteAddr } = require ( '../helpers/git' )
2
+
1
3
function detect ( envs ) {
2
4
return ! ! envs . TEAMCITY_VERSION
3
5
}
@@ -29,7 +31,7 @@ function _getSHA(inputs) {
29
31
30
32
function _getSlug ( inputs ) {
31
33
const { args } = inputs
32
- return args . slug || ''
34
+ return args . slug || parseSlugFromRemoteAddr ( '' ) || ''
33
35
}
34
36
35
37
function _getBuild ( inputs ) {
Original file line number Diff line number Diff line change 1
1
const td = require ( 'testdouble' )
2
+ const childProcess = require ( 'child_process' )
2
3
3
4
const providerTeamCity = require ( '../../src/ci_providers/provider_teamcity' )
4
5
@@ -51,6 +52,47 @@ describe('TeamCity Params', () => {
51
52
service : 'teamcity' ,
52
53
slug : '' ,
53
54
}
55
+ const spawnSync = td . replace ( childProcess , 'spawnSync' )
56
+ td . when (
57
+ spawnSync ( 'git' , [
58
+ 'config' ,
59
+ '--get' ,
60
+ 'remote.origin.url' ,
61
+ ] ) ,
62
+ ) . thenReturn ( { stdout : '' } )
63
+ const params = providerTeamCity . getServiceParams ( inputs )
64
+ expect ( params ) . toMatchObject ( expected )
65
+ } )
66
+
67
+ it ( 'gets correct params and remote slug' , ( ) => {
68
+ const inputs = {
69
+ args : { } ,
70
+ envs : {
71
+ CI : true ,
72
+ TEAMCITY_VERSION : true ,
73
+ BRANCH_NAME : 'main' ,
74
+ BUILD_VCS_NUMBER : 'testingsha' ,
75
+ BUILD_NUMBER : 1 ,
76
+ } ,
77
+ }
78
+ const expected = {
79
+ branch : 'main' ,
80
+ build : 1 ,
81
+ buildURL : '' ,
82
+ commit : 'testingsha' ,
83
+ job : '' ,
84
+ pr : '' ,
85
+ service : 'teamcity' ,
86
+ slug : 'testOrg/testRepo' ,
87
+ }
88
+ const spawnSync = td . replace ( childProcess , 'spawnSync' )
89
+ td . when (
90
+ spawnSync ( 'git' , [
91
+ 'config' ,
92
+ '--get' ,
93
+ 'remote.origin.url' ,
94
+ ] ) ,
95
+ ) . thenReturn ( { stdout : 'https://github.com/testOrg/testRepo.git' } )
54
96
const params = providerTeamCity . getServiceParams ( inputs )
55
97
expect ( params ) . toMatchObject ( expected )
56
98
} )
@@ -72,6 +114,14 @@ describe('TeamCity Params', () => {
72
114
BUILD_NUMBER : 1 ,
73
115
} ,
74
116
}
117
+ const spawnSync = td . replace ( childProcess , 'spawnSync' )
118
+ td . when (
119
+ spawnSync ( 'git' , [
120
+ 'config' ,
121
+ '--get' ,
122
+ 'remote.origin.url' ,
123
+ ] ) ,
124
+ ) . thenReturn ( { stdout : '' } )
75
125
const expected = {
76
126
branch : 'branch' ,
77
127
build : 3 ,
You can’t perform that action at this time.
0 commit comments