@@ -31,6 +31,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3131exports . MsdoClient = void 0 ;
3232const path = __importStar ( require ( "path" ) ) ;
3333const process = __importStar ( require ( "process" ) ) ;
34+ const fs = __importStar ( require ( "fs" ) ) ;
3435const tl = __importStar ( require ( "azure-pipelines-task-lib/task" ) ) ;
3536const msdo_installer_1 = require ( "./msdo-installer" ) ;
3637class 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 }
0 commit comments