Skip to content

Commit 6e5b317

Browse files
committed
v1.2.2
1 parent 46f4156 commit 6e5b317

4 files changed

Lines changed: 23 additions & 9 deletions

File tree

lib/msdo-client.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3131
exports.MsdoClient = void 0;
3232
const path = __importStar(require("path"));
3333
const process = __importStar(require("process"));
34+
const fs = __importStar(require("fs"));
3435
const tl = __importStar(require("azure-pipelines-task-lib/task"));
3536
const msdo_installer_1 = require("./msdo-installer");
3637
class MsdoClient {
@@ -76,9 +77,11 @@ class MsdoClient {
7677
}
7778
});
7879
}
79-
run(args, successfulExitCodes = null) {
80+
run(args, successfulExitCodes = null, publish = true, publishArtifactName = null) {
8081
return __awaiter(this, void 0, void 0, function* () {
8182
let tool = null;
83+
let sarifFile = path.join(process.env.BUILD_STAGINGDIRECTORY, '.gdn', 'msdo.sarif');
84+
tl.debug(`sarifFile = ${sarifFile}`);
8285
try {
8386
if (successfulExitCodes == null) {
8487
successfulExitCodes = [0];
@@ -103,8 +106,6 @@ class MsdoClient {
103106
else if (loggerLevel) {
104107
tool.arg('--logger-level').arg(loggerLevel);
105108
}
106-
let sarifFile = path.join(process.env.BUILD_STAGINGDIRECTORY, '.gdn', 'msdo.sarif');
107-
tl.debug(`sarifFile = ${sarifFile}`);
108109
tl.setVariable('MSDO_SARIF_FILE', sarifFile);
109110
args.push('--export-breaking-results-to-file');
110111
args.push(`${sarifFile}`);
@@ -130,6 +131,12 @@ class MsdoClient {
130131
break;
131132
}
132133
}
134+
if (publish && fs.existsSync(sarifFile)) {
135+
if (this.isNullOrWhiteSpace(publishArtifactName)) {
136+
publishArtifactName = 'CodeAnalysisLogs';
137+
}
138+
console.log(`##vso[artifact.upload artifactname=${publishArtifactName}]${sarifFile}`);
139+
}
133140
if (!success) {
134141
throw `MSDO CLI exited with an error exit code: ${exitCode}`;
135142
}

lib/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "microsoft-security-devops-azdevops-task-lib",
3-
"version": "1.2.1",
3+
"version": "1.2.2",
44
"description": "Microsoft Security DevOps for Azure DevOps task library.",
55
"author": "Microsoft Corporation",
66
"license": "MIT",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "microsoft-security-devops-azdevops-task-lib",
3-
"version": "1.2.1",
3+
"version": "1.2.2",
44
"description": "Microsoft Security DevOps for Azure DevOps task library.",
55
"author": "Microsoft Corporation",
66
"license": "MIT",

src/msdo-client.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,10 @@ export class MsdoClient {
5656
}
5757
}
5858

59-
async run(args: string[], successfulExitCodes: number[] = null) {
59+
async run(args: string[], successfulExitCodes: number[] = null, publish: boolean = true, publishArtifactName: string = null) {
6060
let tool = null;
61+
let sarifFile : string = path.join(process.env.BUILD_STAGINGDIRECTORY, '.gdn', 'msdo.sarif');
62+
tl.debug(`sarifFile = ${sarifFile}`);
6163

6264
try {
6365
if (successfulExitCodes == null) {
@@ -91,9 +93,6 @@ export class MsdoClient {
9193
tool.arg('--logger-level').arg(loggerLevel);
9294
}
9395

94-
let sarifFile : string = path.join(process.env.BUILD_STAGINGDIRECTORY, '.gdn', 'msdo.sarif');
95-
tl.debug(`sarifFile = ${sarifFile}`);
96-
9796
// Write it as a GitHub Action variable for follow up tasks to consume
9897
tl.setVariable('MSDO_SARIF_FILE', sarifFile);
9998

@@ -127,6 +126,14 @@ export class MsdoClient {
127126
}
128127
}
129128

129+
if (publish && fs.existsSync(sarifFile)) {
130+
if (this.isNullOrWhiteSpace(publishArtifactName)) {
131+
publishArtifactName = 'CodeAnalysisLogs';
132+
}
133+
134+
console.log(`##vso[artifact.upload artifactname=${publishArtifactName}]${sarifFile}`);
135+
}
136+
130137
if (!success) {
131138
throw `MSDO CLI exited with an error exit code: ${exitCode}`;
132139
}

0 commit comments

Comments
 (0)