Skip to content

Commit fb3ddf4

Browse files
feat: [SIGINT-2798] Add mark_build_status support and return status code from the action (#51)
- Added support for marking build status as 'success' or 'failure' in the Black Duck Security Scan. - Improved error handling to ensure the correct status code is returned from the action. - Updated test cases to handle scenarios where the exit code is 8 and the build is marked as success. Refs: [SIGINT-2798], [INTEGRATE-169]
1 parent 6c5b984 commit fb3ddf4

File tree

5 files changed

+60
-32
lines changed

5 files changed

+60
-32
lines changed

dist/index.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
1010
exports.POLARIS_SERVERURL_KEY = exports.POLARIS_ASSESSMENT_TYPES_KEY = exports.POLARIS_PROJECT_NAME_KEY = exports.POLARIS_APPLICATION_NAME_KEY = exports.POLARIS_ACCESS_TOKEN_KEY = exports.POLARIS_ACCESSTOKEN_KEY = exports.COVERITY_VERSION_KEY = exports.BRIDGE_COVERITY_VERSION_KEY = exports.COVERITY_LOCAL_KEY = exports.COVERITY_PRCOMMENT_ENABLED_KEY = exports.COVERITY_AUTOMATION_PRCOMMENT_KEY = exports.COVERITY_ARGS_KEY = exports.COVERITY_CONFIG_PATH_KEY = exports.COVERITY_CLEAN_COMMAND_KEY = exports.COVERITY_BUILD_COMMAND_KEY = exports.COVERITY_WAITFORSCAN_KEY = exports.COVERITY_POLICY_VIEW_KEY = exports.COVERITY_INSTALL_DIRECTORY_KEY = exports.COVERITY_STREAM_NAME_KEY = exports.COVERITY_PROJECT_NAME_KEY = exports.COVERITY_PASSPHRASE_KEY = exports.COVERITY_USER_KEY = exports.COVERITY_URL_KEY = exports.DETECT_EXECUTION_PATH_KEY = exports.BLACKDUCK_EXECUTION_PATH_KEY = exports.COVERITY_EXECUTION_PATH_KEY = exports.SRM_WAITFORSCAN_KEY = exports.SRM_BRANCH_PARENT_KEY = exports.SRM_BRANCH_NAME_KEY = exports.SRM_PROJECT_ID_KEY = exports.SRM_PROJECT_NAME_KEY = exports.SRM_ASSESSMENT_TYPES_KEY = exports.SRM_API_KEY = exports.SRM_URL_KEY = exports.SRM_KEY = exports.BLACKDUCK_KEY = exports.POLARIS_KEY = exports.COVERITY_KEY = exports.MIN_SUPPORTED_BRIDGE_CLI_MAC_ARM_VERSION = exports.BRIDGE_CLI_DOWNLOAD_VERSION_KEY = exports.BRIDGE_DOWNLOAD_VERSION_KEY = exports.BRIDGE_CLI_DOWNLOAD_URL_KEY = exports.BRIDGE_DOWNLOAD_URL_KEY = exports.BRIDGE_CLI_INSTALL_DIRECTORY_KEY = exports.BRIDGE_INSTALL_DIRECTORY_KEY = exports.APPLICATION_NAME = exports.BRIDGE_CLI_ARTIFACTORY_URL = exports.BRIDGE_CLI_DEFAULT_PATH_LINUX = exports.BRIDGE_CLI_DEFAULT_PATH_WINDOWS = exports.BRIDGE_CLI_DEFAULT_PATH_MAC = void 0;
1111
exports.BLACKDUCKSCA_UPLOAD_SARIF_REPORT_KEY = exports.BLACKDUCK_UPLOAD_SARIF_REPORT_KEY = exports.BLACKDUCKSCA_REPORTS_SARIF_GROUP_SCA_ISSUES_KEY = exports.BLACKDUCK_REPORTS_SARIF_GROUP_SCA_ISSUES_KEY = exports.BLACKDUCKSCA_REPORTS_SARIF_SEVERITIES_KEY = exports.BLACKDUCK_REPORTS_SARIF_SEVERITIES_KEY = exports.BLACKDUCKSCA_REPORTS_SARIF_FILE_PATH_KEY = exports.BLACKDUCK_REPORTS_SARIF_FILE_PATH_KEY = exports.BLACKDUCKSCA_REPORTS_SARIF_CREATE_KEY = exports.BLACKDUCK_REPORTS_SARIF_CREATE_KEY = exports.BLACKDUCKSCA_PRCOMMENT_ENABLED_KEY = exports.BLACKDUCK_PRCOMMENT_ENABLED_KEY = exports.BLACKDUCKSCA_FIXPR_UPGRADE_GUIDANCE_KEY = exports.BLACKDUCK_FIXPR_USE_UPGRADE_GUIDANCE_KEY = exports.BLACKDUCKSCA_FIXPR_FILTER_SEVERITIES_KEY = exports.BLACKDUCK_FIXPR_FILTER_SEVERITIES_KEY = exports.BLACKDUCKSCA_FIXPR_CREATE_SINGLE_PR_KEY = exports.BLACKDUCK_FIXPR_CREATE_SINGLE_PR_KEY = exports.BLACKDUCKSCA_FIXPR_MAX_COUNT_KEY = exports.BLACKDUCK_FIXPR_MAXCOUNT_KEY = exports.BLACKDUCKSCA_FIXPR_ENABLED_KEY = exports.BLACKDUCK_FIXPR_ENABLED_KEY = exports.BLACKDUCKSCA_SCAN_FAILURE_SEVERITIES_KEY = exports.BLACKDUCK_SCAN_FAILURE_SEVERITIES_KEY = exports.BLACKDUCKSCA_SCAN_FULL_KEY = exports.BLACKDUCK_SCAN_FULL_KEY = exports.DETECT_INSTALL_DIRECTORY_KEY = exports.BLACKDUCK_INSTALL_DIRECTORY_KEY = exports.BLACKDUCKSCA_TOKEN_KEY = exports.BLACKDUCK_TOKEN_KEY = exports.BLACKDUCKSCA_URL_KEY = exports.BLACKDUCK_URL_KEY = exports.PROJECT_DIRECTORY_KEY = exports.PROJECT_SOURCE_EXCLUDES_KEY = exports.PROJECT_SOURCE_PRESERVESYMLINKS_KEY = exports.PROJECT_SOURCE_ARCHIVE_KEY = exports.POLARIS_ASSESSMENT_MODE_KEY = exports.POLARIS_WAITFORSCAN_KEY = exports.POLARIS_UPLOAD_SARIF_REPORT_KEY = exports.POLARIS_REPORTS_SARIF_ISSUE_TYPES_KEY = exports.POLARIS_REPORTS_SARIF_GROUP_SCA_ISSUES_KEY = exports.POLARIS_REPORTS_SARIF_SEVERITIES_KEY = exports.POLARIS_REPORTS_SARIF_FILE_PATH_KEY = exports.POLARIS_REPORTS_SARIF_CREATE_KEY = exports.POLARIS_TEST_SCA_TYPE_KEY = exports.POLARIS_BRANCH_PARENT_NAME_KEY = exports.POLARIS_BRANCH_NAME_KEY = exports.POLARIS_PRCOMMENT_SEVERITIES_KEY = exports.POLARIS_PRCOMMENT_ENABLED_KEY = exports.POLARIS_SERVER_URL_KEY = void 0;
1212
exports.BRIDGE_EXECUTABLE_NOT_FOUND_ERROR = exports.BRIDGE_CLI_URL_EMPTY_ERROR = exports.PROVIDED_BRIDGE_CLI_URL_EMPTY_ERROR = exports.BRIDGE_CLI_URL_NOT_VALID_ERROR = exports.BRIDGE_CLI_URL_NOT_VALID_OS_ERROR = exports.BRIDGE_VERSION_NOT_FOUND_ERROR = exports.MISSING_GITHUB_TOKEN_FOR_FIX_PR_AND_PR_COMMENT_ERROR = exports.GITHUB_TOKEN_VALIDATION_SARIF_UPLOAD_ERROR = exports.BLACKDUCK_FIXPR_LOG_INFO_FOR_PR_SCANS = exports.BLACKDUCK_PR_COMMENT_LOG_INFO_FOR_NON_PR_SCANS = exports.COVERITY_PR_COMMENT_LOG_INFO_FOR_NON_PR_SCANS = exports.POLARIS_PR_COMMENT_LOG_INFO_FOR_NON_PR_SCANS = exports.SARIF_REPORT_LOG_INFO_FOR_PR_SCANS = exports.GITHUB_ENVIRONMENT_VARIABLES = exports.HTTP_STATUS_FORBIDDEN = exports.HTTP_STATUS_ACCEPTED = exports.HTTP_STATUS_OK = exports.SECONDARY_RATE_LIMIT = exports.X_RATE_LIMIT_REMAINING = exports.X_RATE_LIMIT_RESET = exports.SARIF_DEFAULT_FILE_NAME = exports.POLARIS_SARIF_ARTIFACT_NAME = exports.POLARIS_SARIF_GENERATOR_DIRECTORY = exports.BLACKDUCK_SARIF_ARTIFACT_NAME = exports.BLACKDUCK_SARIF_GENERATOR_DIRECTORY = exports.BRIDGE_LOCAL_DIRECTORY = exports.GITHUB_CLOUD_API_URL = exports.GITHUB_CLOUD_URL = exports.NON_RETRY_HTTP_CODES = exports.RETRY_COUNT = exports.RETRY_DELAY_IN_MILLISECONDS = exports.EXIT_CODE_MAP = exports.DIAGNOSTICS_RETENTION_DAYS_KEY = exports.NETWORK_AIRGAP_KEY = exports.BRIDGE_NETWORK_AIRGAP_KEY = exports.INCLUDE_DIAGNOSTICS_KEY = exports.GITHUB_TOKEN_KEY = exports.GITHUB_HOST_URL_KEY = exports.BLACKDUCKSCA_POLICY_BADGES_MAX_COUNT_KEY = exports.BLACKDUCK_POLICY_BADGES_MAX_COUNT_KEY = exports.BLACKDUCKSCA_POLICY_BADGES_CREATE_KEY = exports.BLACKDUCK_POLICY_BADGES_CREATE_KEY = exports.DETECT_ARGS_KEY = exports.BLACKDUCK_ARGS_KEY = exports.DETECT_CONFIG_PATH_KEY = exports.BLACKDUCK_CONFIG_PATH_KEY = exports.DETECT_SEARCH_DEPTH_KEY = exports.BLACKDUCK_SEARCH_DEPTH_KEY = exports.BLACKDUCKSCA_WAITFORSCAN_KEY = exports.BLACKDUCK_WAITFORSCAN_KEY = void 0;
13-
exports.TASK_RETURN_STATUS = exports.MARK_BUILD_STATUS_DEFAULT = exports.BUILD_STATUS = exports.MARK_BUILD_STATUS_KEY = exports.RETURN_STATUS_KEY = exports.POLARIS_POLICY_BADGES_MAX_COUNT_KEY = exports.POLARIS_POLICY_BADGES_CREATE_KEY = exports.WINDOWS_PLATFORM_NAME = exports.LINUX_PLATFORM_NAME = exports.MAC_PLATFORM_NAME = exports.SARIF_FILE_NO_FOUND_FOR_UPLOAD_ERROR = exports.SARIF_GAS_UPLOAD_FAILED_ERROR = exports.SARIF_GAS_API_RATE_LIMIT_FOR_ERROR = exports.PROVIDED_BLACKDUCKSCA_FAILURE_SEVERITIES_ERROR = exports.MISSING_BOOLEAN_VALUE_ERROR = exports.INVALID_VALUE_ERROR = exports.BRIDGE_DOWNLOAD_RETRY_ERROR = exports.BRIDGE_EXTRACT_directory_NOT_FOUND_ERROR = exports.BRIDGE_ZIP_NOT_FOUND_FOR_EXTRACT_ERROR = exports.SCAN_TYPE_REQUIRED_ERROR = exports.BRIDGE_DEFAULT_DIRECTORY_NOT_FOUND_ERROR = exports.BRIDGE_INSTALL_DIRECTORY_NOT_FOUND_ERROR = void 0;
13+
exports.EXIT_CODE_ERROR = exports.TASK_RETURN_STATUS = exports.MARK_BUILD_STATUS_DEFAULT = exports.BUILD_STATUS = exports.MARK_BUILD_STATUS_KEY = exports.RETURN_STATUS_KEY = exports.POLARIS_POLICY_BADGES_MAX_COUNT_KEY = exports.POLARIS_POLICY_BADGES_CREATE_KEY = exports.WINDOWS_PLATFORM_NAME = exports.LINUX_PLATFORM_NAME = exports.MAC_PLATFORM_NAME = exports.SARIF_FILE_NO_FOUND_FOR_UPLOAD_ERROR = exports.SARIF_GAS_UPLOAD_FAILED_ERROR = exports.SARIF_GAS_API_RATE_LIMIT_FOR_ERROR = exports.PROVIDED_BLACKDUCKSCA_FAILURE_SEVERITIES_ERROR = exports.MISSING_BOOLEAN_VALUE_ERROR = exports.INVALID_VALUE_ERROR = exports.BRIDGE_DOWNLOAD_RETRY_ERROR = exports.BRIDGE_EXTRACT_directory_NOT_FOUND_ERROR = exports.BRIDGE_ZIP_NOT_FOUND_FOR_EXTRACT_ERROR = exports.SCAN_TYPE_REQUIRED_ERROR = exports.BRIDGE_DEFAULT_DIRECTORY_NOT_FOUND_ERROR = exports.BRIDGE_INSTALL_DIRECTORY_NOT_FOUND_ERROR = void 0;
1414
exports.BRIDGE_CLI_DEFAULT_PATH_MAC = '/bridge-cli-bundle'; //Path will be in home
1515
exports.BRIDGE_CLI_DEFAULT_PATH_WINDOWS = '\\bridge-cli-bundle';
1616
exports.BRIDGE_CLI_DEFAULT_PATH_LINUX = '/bridge-cli-bundle';
@@ -302,6 +302,7 @@ var BUILD_STATUS;
302302
})(BUILD_STATUS = exports.BUILD_STATUS || (exports.BUILD_STATUS = {}));
303303
exports.MARK_BUILD_STATUS_DEFAULT = BUILD_STATUS.FAILURE;
304304
exports.TASK_RETURN_STATUS = 'status';
305+
exports.EXIT_CODE_ERROR = 8;
305306

306307

307308
/***/ }),
@@ -2764,14 +2765,21 @@ function run() {
27642765
}
27652766
// Execute bridge command
27662767
exitCode = yield sb.executeBridgeCommand(formattedCommand, (0, config_1.getGitHubWorkspaceDir)());
2767-
isBridgeExecuted = exitCode === 0 || (exitCode === 8 && (0, utility_1.checkJobResult)(inputs.MARK_BUILD_STATUS) === constants.BUILD_STATUS.SUCCESS);
2768-
(0, core_1.info)(exitCode === 8 && isBridgeExecuted ? `Marking the build ${inputs.MARK_BUILD_STATUS} as configured in the task.` : 'Black Duck Security Action workflow execution completed successfully.');
2768+
if (exitCode === 0) {
2769+
(0, core_1.info)('Black Duck Security Action workflow execution completed successfully.');
2770+
isBridgeExecuted = true;
2771+
}
27692772
return exitCode;
27702773
}
27712774
catch (error) {
2772-
exitCode = getBridgeExitCodeAsNumericValue(error);
2773-
isBridgeExecuted = getBridgeExitCode(error);
2774-
throw error;
2775+
const err = error;
2776+
exitCode = getBridgeExitCodeAsNumericValue(err);
2777+
if (exitCode === constants.EXIT_CODE_ERROR && (0, utility_1.checkJobResult)(inputs.MARK_BUILD_STATUS) === constants.BUILD_STATUS.SUCCESS) {
2778+
(0, core_1.info)(`Workflow failed! ${logBridgeExitCodes(err.message)}.\nMarking the build ${inputs.MARK_BUILD_STATUS} as configured in the task.`);
2779+
isBridgeExecuted = true;
2780+
}
2781+
else
2782+
throw error;
27752783
}
27762784
finally {
27772785
// The statement set the exit code in the 'status' variable which can be used in the YAML file

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/application-constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,3 +300,4 @@ export enum BUILD_STATUS {
300300
}
301301
export const MARK_BUILD_STATUS_DEFAULT = BUILD_STATUS.FAILURE
302302
export const TASK_RETURN_STATUS = 'status'
303+
export const EXIT_CODE_ERROR = 8

src/main.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {debug, info, setFailed, setOutput, getInput} from '@actions/core'
1+
import {debug, info, setFailed, setOutput} from '@actions/core'
22
import {checkJobResult, cleanupTempDir, createTempDir, isPullRequestEvent, parseToBoolean} from './blackduck-security-action/utility'
33
import {Bridge} from './blackduck-security-action/bridge-cli'
44
import {getGitHubWorkspaceDir as getGitHubWorkspaceDirV2} from 'actions-artifact-v2/lib/internal/shared/config'
@@ -7,6 +7,7 @@ import * as inputs from './blackduck-security-action/inputs'
77
import {uploadDiagnostics, uploadSarifReportAsArtifact} from './blackduck-security-action/artifacts'
88
import {isNullOrEmptyValue} from './blackduck-security-action/validators'
99
import {GitHubClientServiceFactory} from './blackduck-security-action/factory/github-client-service-factory'
10+
import {EXIT_CODE_ERROR} from './application-constants'
1011

1112
export async function run() {
1213
info('Black Duck Security Action started...')
@@ -28,13 +29,18 @@ export async function run() {
2829
}
2930
// Execute bridge command
3031
exitCode = await sb.executeBridgeCommand(formattedCommand, getGitHubWorkspaceDirV2())
31-
isBridgeExecuted = exitCode === 0 || (exitCode === 8 && checkJobResult(inputs.MARK_BUILD_STATUS) === constants.BUILD_STATUS.SUCCESS)
32-
info(exitCode === 8 && isBridgeExecuted ? `Marking the build ${inputs.MARK_BUILD_STATUS} as configured in the task.` : 'Black Duck Security Action workflow execution completed successfully.')
32+
if (exitCode === 0) {
33+
info('Black Duck Security Action workflow execution completed successfully.')
34+
isBridgeExecuted = true
35+
}
3336
return exitCode
3437
} catch (error) {
35-
exitCode = getBridgeExitCodeAsNumericValue(error as Error)
36-
isBridgeExecuted = getBridgeExitCode(error as Error)
37-
throw error
38+
const err = error as Error
39+
exitCode = getBridgeExitCodeAsNumericValue(err)
40+
if (exitCode === constants.EXIT_CODE_ERROR && checkJobResult(inputs.MARK_BUILD_STATUS) === constants.BUILD_STATUS.SUCCESS) {
41+
info(`Workflow failed! ${logBridgeExitCodes(err.message)}.\nMarking the build ${inputs.MARK_BUILD_STATUS} as configured in the task.`)
42+
isBridgeExecuted = true
43+
} else throw error
3844
} finally {
3945
// The statement set the exit code in the 'status' variable which can be used in the YAML file
4046
if (parseToBoolean(inputs.RETURN_STATUS)) {

test/unit/main.test.ts

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {logBridgeExitCodes, run} from '../../src/main'
1+
import {getBridgeExitCode, logBridgeExitCodes, run} from '../../src/main'
22
import * as inputs from '../../src/blackduck-security-action/inputs'
33
import {Bridge} from '../../src/blackduck-security-action/bridge-cli'
44
import {DownloadFileResponse} from '../../src/blackduck-security-action/download-utility'
@@ -49,7 +49,7 @@ describe('Black Duck Security Action: Handling isBridgeExecuted and Exit Code In
4949
}
5050
}
5151

52-
const setupMocks = (exitCode: number) => {
52+
const setupMocks = () => {
5353
jest.spyOn(Bridge.prototype, 'getBridgeVersionFromLatestURL').mockResolvedValueOnce('0.1.0')
5454
const downloadFileResp: DownloadFileResponse = {
5555
filePath: 'C://user/temp/download/',
@@ -58,7 +58,6 @@ describe('Black Duck Security Action: Handling isBridgeExecuted and Exit Code In
5858
jest.spyOn(downloadUtility, 'getRemoteFile').mockResolvedValueOnce(downloadFileResp)
5959
jest.spyOn(downloadUtility, 'extractZipped').mockResolvedValueOnce(true)
6060
jest.spyOn(configVariables, 'getGitHubWorkspaceDir').mockReturnValueOnce('/home/bridge')
61-
jest.spyOn(Bridge.prototype, 'executeBridgeCommand').mockResolvedValueOnce(exitCode)
6261
const uploadResponse: UploadArtifactResponse = {size: 0, id: 123}
6362
jest.spyOn(diagnostics, 'uploadDiagnostics').mockResolvedValueOnce(uploadResponse)
6463
}
@@ -69,7 +68,8 @@ describe('Black Duck Security Action: Handling isBridgeExecuted and Exit Code In
6968

7069
it('handles successful execution with exitCode 0', async () => {
7170
setupBlackDuckInputs()
72-
setupMocks(0)
71+
setupMocks()
72+
jest.spyOn(Bridge.prototype, 'executeBridgeCommand').mockResolvedValueOnce(0)
7373
const response = await run()
7474

7575
expect(response).toBe(0)
@@ -80,25 +80,30 @@ describe('Black Duck Security Action: Handling isBridgeExecuted and Exit Code In
8080

8181
it('handles issues detected but marked as success with exitCode 8', async () => {
8282
setupBlackDuckInputs({MARK_BUILD_STATUS: 'success'})
83-
setupMocks(8)
83+
setupMocks()
84+
jest.spyOn(Bridge.prototype, 'executeBridgeCommand').mockRejectedValueOnce(new Error('Bridge CLI execution failed with exit code 8'))
8485
jest.spyOn(utility, 'checkJobResult').mockReturnValue('success')
8586

86-
const response = await run()
87-
88-
expect(response).toBe(8)
89-
expect(core.info).toHaveBeenCalledWith('Marking the build success as configured in the task.')
90-
expect(core.setOutput).toHaveBeenCalledWith('status', 8)
91-
expect(core.debug).toHaveBeenCalledWith('Bridge CLI execution completed: true')
87+
try {
88+
await run()
89+
} catch (error: any) {
90+
expect(error.message).toContain('Exit Code: 8')
91+
expect(core.info).toHaveBeenCalledWith('Marking the build success as configured in the task.')
92+
expect(core.setOutput).toHaveBeenCalledWith('status', 8)
93+
expect(core.debug).toHaveBeenCalledWith('Bridge CLI execution completed: true')
94+
}
9295
})
9396

9497
it('handles failure case with exitCode 2', async () => {
9598
setupBlackDuckInputs()
96-
setupMocks(2)
99+
setupMocks()
100+
jest.spyOn(Bridge.prototype, 'executeBridgeCommand').mockRejectedValueOnce(new Error('Exit Code: 2 Error from adapter end'))
97101

98-
const response = await run()
99-
expect(response).toBe(2)
100-
expect(core.setOutput).toHaveBeenCalledWith('status', 2)
101-
expect(core.debug).toHaveBeenCalledWith('Bridge CLI execution completed: false')
102+
try {
103+
await run()
104+
} catch (error: any) {
105+
expect(error.message).toContain('Exit Code: 2 Error from adapter end')
106+
}
102107
})
103108

104109
it('uploads SARIF report for exitCode 8', async () => {
@@ -107,14 +112,22 @@ describe('Black Duck Security Action: Handling isBridgeExecuted and Exit Code In
107112
BLACKDUCKSCA_REPORTS_SARIF_FILE_PATH: '/',
108113
MARK_BUILD_STATUS: 'success'
109114
})
110-
setupMocks(8)
115+
setupMocks()
116+
jest.spyOn(Bridge.prototype, 'executeBridgeCommand').mockRejectedValueOnce(new Error('Bridge CLI execution failed with exit code 8'))
111117
jest.spyOn(utility, 'checkJobResult').mockReturnValue('success')
112118
jest.spyOn(utility, 'isPullRequestEvent').mockReturnValue(false)
113119
const uploadResponse: UploadArtifactResponse = {size: 0, id: 123}
114120
jest.spyOn(diagnostics, 'uploadSarifReportAsArtifact').mockResolvedValueOnce(uploadResponse)
115121

116-
await run()
117-
expect(diagnostics.uploadSarifReportAsArtifact).toHaveBeenCalledWith('Blackduck SCA SARIF Generator', '/', 'blackduck_sarif_report')
122+
const error = new Error('Error: The process failed with exit code 8')
123+
expect(getBridgeExitCode(error)).toBe(true)
124+
125+
try {
126+
await run()
127+
} catch (error: any) {
128+
expect(error.message).toContain('Exit Code: 8')
129+
expect(diagnostics.uploadSarifReportAsArtifact).toHaveBeenCalledWith('blackduck-sca-sarif-generator', '/', 'blackduck-sca-sarif-artifact')
130+
}
118131
})
119132
})
120133

0 commit comments

Comments
 (0)