From 7b563e311ce58d330d4b0927c2190efa7279bac7 Mon Sep 17 00:00:00 2001 From: Igor Lomba <114568996+igorlombacx@users.noreply.github.com> Date: Mon, 30 Oct 2023 10:57:53 +0000 Subject: [PATCH] Setting scan ID as an output variable (#431) * setting scan ID as an output variable * fix issue --------- Co-authored-by: Pedro Lopes --- cxAstScan/services/TaskRunner.ts | 7 ++++--- cxAstScan/task.json | 8 +++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/cxAstScan/services/TaskRunner.ts b/cxAstScan/services/TaskRunner.ts index 082db77..1ee0aa2 100644 --- a/cxAstScan/services/TaskRunner.ts +++ b/cxAstScan/services/TaskRunner.ts @@ -4,7 +4,7 @@ import {CxWrapper} from "@checkmarxdev/ast-cli-javascript-wrapper"; import {CxCommandOutput} from "@checkmarxdev/ast-cli-javascript-wrapper/dist/main/wrapper/CxCommandOutput"; import {CxParamType} from "@checkmarxdev/ast-cli-javascript-wrapper/dist/main/wrapper/CxParamType"; import CxScan from "@checkmarxdev/ast-cli-javascript-wrapper/dist/main/scan/CxScan"; -import { getConfiguration, getLogFilename } from "./Utils"; +import {getConfiguration, getLogFilename} from "./Utils"; export class TaskRunner { @@ -28,9 +28,9 @@ export class TaskRunner { console.log("Additional Params: " + additionalParams); - try { + try { //Write to file to test if possible to read from file in cleanup post execution event - + const wrapper = new CxWrapper(cxScanConfig, getLogFilename()); const cxCommandOutput: CxCommandOutput = await wrapper.scanCreate(params); @@ -42,6 +42,7 @@ export class TaskRunner { const scan: CxScan = cxCommandOutput.payload.pop(); if (agentTempDirectory && scan && scan.id) { + taskLib.setVariable("CxOneScanId", scan.id); await this.generateResults(wrapper, agentTempDirectory, scan.id); } } diff --git a/cxAstScan/task.json b/cxAstScan/task.json index 590aeee..41f8250 100644 --- a/cxAstScan/task.json +++ b/cxAstScan/task.json @@ -77,5 +77,11 @@ } }, "messages": { - } + }, + "OutputVariables": [ + { + "name": "CxOneScanId", + "description": "Checkmarx One scan ID from created scan" + } + ] }