@@ -95,8 +95,8 @@ export class CodeCoveragePublisher {
95
95
shell . cp ( '-f' , summaryFile , newReportDirectory ) ;
96
96
97
97
_this . command . info ( "PublishCodeCoverageFiles : Publishing code coverage report '" + newReportDirectory + "'" ) ;
98
-
99
- _this . uploadArtifact ( newReportDirectory , codeCoverageArtifactName , containerId ) . then ( function ( ) {
98
+
99
+ _this . uploadArtifact ( newReportDirectory , codeCoverageArtifactName , containerId , _this . isReportDirectoryBrowsable ( newReportDirectory ) ) . then ( function ( ) {
100
100
try {
101
101
_this . command . info ( "PublishCodeCoverageFiles : Code coverage report published successfully." ) ;
102
102
@@ -118,7 +118,7 @@ export class CodeCoveragePublisher {
118
118
var rawFilesArtifactName = "Code Coverage Files_" + _this . buildId ;
119
119
120
120
_this . command . info ( "PublishCodeCoverageFiles : Publishing additional code coverage files '" + rawFilesDirectory + "'" ) ;
121
- _this . uploadArtifact ( rawFilesDirectory , rawFilesArtifactName , containerId ) . then ( function ( ) {
121
+ _this . uploadArtifact ( rawFilesDirectory , rawFilesArtifactName , containerId , "False" ) . then ( function ( ) {
122
122
// clean the temporary additional files folder created.
123
123
shell . rm ( '-rf' , rawFilesDirectory ) ;
124
124
@@ -171,17 +171,20 @@ export class CodeCoveragePublisher {
171
171
// - artifactName: name of teh artifact
172
172
// - containerId: containerId
173
173
//-----------------------------------------------------
174
- private uploadArtifact ( path : string , artifactName : string , containerId : number ) : Q . Promise < any > {
174
+ private uploadArtifact ( path : string , artifactName : string , containerId : number , browsable : string ) : Q . Promise < any > {
175
175
var defer = Q . defer ( ) ;
176
+ var properties = { } ;
177
+ properties [ "browsable" ] = browsable ;
176
178
fc . copyToFileContainer ( this . executionContext , path , containerId , "/" + artifactName ) . then ( ( artifactLocation : string ) => {
177
179
try {
178
180
this . command . info ( 'Associating artifact ' + artifactLocation + ' ...' ) ;
179
181
var artifact : buildifm . BuildArtifact = < buildifm . BuildArtifact > {
180
182
name : artifactName ,
181
183
resource : {
182
184
type : "container" ,
183
- data : artifactLocation
184
- }
185
+ data : artifactLocation ,
186
+ properties : properties
187
+ } ,
185
188
} ;
186
189
187
190
this . executionContext . service . postArtifact ( this . project , this . buildId , artifact ) . fail ( function ( err ) {
@@ -201,6 +204,17 @@ export class CodeCoveragePublisher {
201
204
return defer . promise ;
202
205
}
203
206
207
+ //-----------------------------------------------------
208
+ // Finds if the report directory has index.html
209
+ // - reportDirectory: string - report directory
210
+ //-----------------------------------------------------
211
+ private isReportDirectoryBrowsable ( reportDirectory : string ) : string {
212
+ var defaultIndexFile = path . join ( reportDirectory , "index.html" ) ;
213
+ if ( utilities . isPathExists ( defaultIndexFile ) && fs . lstatSync ( defaultIndexFile ) . isFile ( ) ) {
214
+ return "True" ;
215
+ }
216
+ return "False" ;
217
+ }
204
218
205
219
//-----------------------------------------------------
206
220
// Read code coverage results from summary file.
0 commit comments