Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit edcedff

Browse files
committed
Fix to make code coverage artifact browsable
1 parent 85e3e94 commit edcedff

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

src/agent/codecoveragepublisher.ts

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ export class CodeCoveragePublisher {
9595
shell.cp('-f', summaryFile, newReportDirectory);
9696

9797
_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() {
100100
try {
101101
_this.command.info("PublishCodeCoverageFiles : Code coverage report published successfully.");
102102

@@ -118,7 +118,7 @@ export class CodeCoveragePublisher {
118118
var rawFilesArtifactName = "Code Coverage Files_" + _this.buildId;
119119

120120
_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() {
122122
// clean the temporary additional files folder created.
123123
shell.rm('-rf', rawFilesDirectory);
124124

@@ -171,17 +171,20 @@ export class CodeCoveragePublisher {
171171
// - artifactName: name of teh artifact
172172
// - containerId: containerId
173173
//-----------------------------------------------------
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> {
175175
var defer = Q.defer();
176+
var properties = {};
177+
properties["browsable"] = browsable;
176178
fc.copyToFileContainer(this.executionContext, path, containerId, "/" + artifactName).then((artifactLocation: string) => {
177179
try {
178180
this.command.info('Associating artifact ' + artifactLocation + ' ...');
179181
var artifact: buildifm.BuildArtifact = <buildifm.BuildArtifact>{
180182
name: artifactName,
181183
resource: {
182184
type: "container",
183-
data: artifactLocation
184-
}
185+
data: artifactLocation,
186+
properties: properties
187+
},
185188
};
186189

187190
this.executionContext.service.postArtifact(this.project, this.buildId, artifact).fail(function(err) {
@@ -201,6 +204,17 @@ export class CodeCoveragePublisher {
201204
return defer.promise;
202205
}
203206

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+
}
204218

205219
//-----------------------------------------------------
206220
// Read code coverage results from summary file.

0 commit comments

Comments
 (0)