@@ -31,7 +31,7 @@ export function beforeJob(executionContext: cm.IExecutionContext, callback) {
31
31
32
32
var job : agentifm . JobRequestMessage = executionContext . jobInfo . jobMessage ;
33
33
var variables : { [ key : string ] : string } = job . environment . variables ;
34
-
34
+
35
35
//
36
36
// Get the valid scm providers and filter endpoints
37
37
//
@@ -42,13 +42,13 @@ export function beforeJob(executionContext: cm.IExecutionContext, callback) {
42
42
supported . push ( path . basename ( provPath , '.js' ) ) ;
43
43
} )
44
44
executionContext . debug ( 'valid scm providers: ' + supported ) ;
45
-
45
+
46
46
var endpoints : agentifm . ServiceEndpoint [ ] = job . environment . endpoints ;
47
47
var srcendpoints = endpoints . filter ( function ( endpoint : agentifm . ServiceEndpoint ) {
48
48
if ( ! endpoint . type ) {
49
49
return false ;
50
50
}
51
-
51
+
52
52
executionContext . info ( 'Repository type: ' + endpoint . type ) ;
53
53
return ( supported . indexOf ( endpoint . type . toLowerCase ( ) ) >= 0 ) ;
54
54
} ) ;
@@ -57,7 +57,7 @@ export function beforeJob(executionContext: cm.IExecutionContext, callback) {
57
57
callback ( new Error ( 'Unsupported SCM system. Supported: ' + supported . toString ( ) ) ) ;
58
58
return ;
59
59
}
60
-
60
+
61
61
// only support 1 SCM system
62
62
var endpoint : agentifm . ServiceEndpoint = srcendpoints [ 0 ] ;
63
63
@@ -68,32 +68,32 @@ export function beforeJob(executionContext: cm.IExecutionContext, callback) {
68
68
var providerType = endpoint . type . toLowerCase ( ) ;
69
69
executionContext . info ( 'using source provider: ' + providerType ) ;
70
70
71
- try {
71
+ try {
72
72
var provPath = path . join ( executionContext . scmPath , providerType ) ;
73
73
executionContext . info ( 'loading: ' + provPath ) ;
74
74
scmm = require ( provPath ) ;
75
75
}
76
76
catch ( err ) {
77
77
callback ( new Error ( 'Source Provider failed to load: ' + providerType ) ) ;
78
- return ;
78
+ return ;
79
79
}
80
-
80
+
81
81
if ( ! scmm . getProvider ) {
82
82
callback ( new Error ( 'SCM Provider does not implement getProvider: ' + providerType ) ) ;
83
83
return ;
84
84
}
85
-
85
+
86
86
var scmProvider : cm . IScmProvider = scmm . getProvider ( executionContext , endpoint ) ;
87
87
scmProvider . initialize ( ) ;
88
88
scmProvider . debugOutput = executionContext . debugOutput ;
89
89
var hashKey : string = scmProvider . hashKey ;
90
-
90
+
91
91
//
92
92
// Get source mappings and set variables
93
93
//
94
94
var workingFolder = variables [ cm . vars . agentWorkingDirectory ] ;
95
95
var repoPath : string ;
96
-
96
+
97
97
var sm : smm . SourceMappings = new smm . SourceMappings ( workingFolder , executionContext . hostContext ) ;
98
98
sm . supportsLegacyPaths = endpoint . type !== 'tfsversioncontrol' ;
99
99
sm . getSourceMapping ( hashKey , job , endpoint )
@@ -102,10 +102,10 @@ export function beforeJob(executionContext: cm.IExecutionContext, callback) {
102
102
103
103
//
104
104
// Variables
105
- //
105
+ //
106
106
// back compat
107
- variables [ 'build.sourceDirectory' ] = repoPath ;
108
-
107
+ variables [ 'build.sourceDirectory' ] = repoPath ;
108
+
109
109
variables [ cm . vars . buildSourcesDirectory ] = repoPath ;
110
110
variables [ cm . vars . systemDefaultWorkingDirectory ] = repoPath ;
111
111
variables [ cm . vars . buildArtifactStagingDirectory ] = path . join ( workingFolder , srcMap . build_artifactstagingdirectory ) ;
@@ -114,10 +114,10 @@ export function beforeJob(executionContext: cm.IExecutionContext, callback) {
114
114
variables [ cm . vars . buildStagingDirectory ] = variables [ cm . vars . buildArtifactStagingDirectory ] ;
115
115
116
116
variables [ cm . vars . commonTestResultsDirectory ] = path . join ( workingFolder , srcMap . common_testresultsdirectory ) ;
117
- var bd = variables [ cm . vars . agentBuildDirectory ] = path . join ( workingFolder , srcMap . agent_builddirectory ) ;
117
+ var bd = variables [ cm . vars . agentBuildDirectory ] = variables [ cm . vars . buildBinariesDirectory ] = path . join ( workingFolder , srcMap . agent_builddirectory ) ;
118
118
shell . mkdir ( '-p' , bd ) ;
119
119
shell . cd ( bd ) ;
120
-
120
+
121
121
//
122
122
// Do the work, optionally clean and get sources
123
123
//
@@ -130,7 +130,7 @@ export function beforeJob(executionContext: cm.IExecutionContext, callback) {
130
130
}
131
131
else {
132
132
executionContext . info ( 'running clean' ) ;
133
- return scmProvider . clean ( ) ;
133
+ return scmProvider . clean ( ) ;
134
134
}
135
135
}
136
136
else {
@@ -158,16 +158,16 @@ export function beforeJob(executionContext: cm.IExecutionContext, callback) {
158
158
if ( ! taskDef ) {
159
159
throw new Error ( 'Task definition for ' + task . id + ' not found.' ) ;
160
160
}
161
-
161
+
162
162
// find the filePath inputs
163
163
var filePathInputs : { [ key : string ] : boolean } = { } ;
164
164
taskDef . inputs . forEach ( ( input : agentifm . TaskInputDefinition ) => {
165
165
if ( input . type === 'filePath' ) {
166
166
filePathInputs [ input . name ] = true ;
167
- trace . write ( 'filePath input: ' + input . name ) ;
167
+ trace . write ( 'filePath input: ' + input . name ) ;
168
168
}
169
169
} ) ;
170
-
170
+
171
171
// scan dictionary of input/val for pathInputs
172
172
for ( var key in task . inputs ) {
173
173
if ( filePathInputs . hasOwnProperty ( key ) ) {
@@ -177,7 +177,7 @@ export function beforeJob(executionContext: cm.IExecutionContext, callback) {
177
177
trace . write ( 'rewriting ' + key + ' to ' + resolvedPath ) ;
178
178
task . inputs [ key ] = resolvedPath ;
179
179
}
180
- }
180
+ }
181
181
} ) ;
182
182
183
183
return 0 ;
@@ -186,7 +186,7 @@ export function beforeJob(executionContext: cm.IExecutionContext, callback) {
186
186
executionContext . info ( 'CD: ' + repoPath ) ;
187
187
shell . cd ( repoPath ) ;
188
188
callback ( ) ;
189
- } )
189
+ } )
190
190
. fail ( ( err ) => {
191
191
callback ( err ) ;
192
192
return ;
0 commit comments