1
0
Fork 0
mirror of synced 2026-06-05 19:18:19 +00:00

Fix #403: Catch the error thrown in pre and post steps (#407)

* fix #403

* modify error handling
This commit is contained in:
Shiying Chen 2024-01-17 17:37:07 +08:00 committed by GitHub
commit aeb0c3630a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 1 additions and 7 deletions

View file

@ -10,7 +10,7 @@ async function cleanup() {
}
}
catch (error) {
core.setFailed(`Login cleanup failed with ${error}. Make sure 'az' is installed on the runner. If 'enable-AzPSSession' is true, make sure 'pwsh' is installed on the runner together with Azure PowerShell module.`);
core.warning(`Login cleanup failed with ${error}. Cleanup will be skipped.`);
core.debug(error.stack);
}
}

View file

@ -13,9 +13,6 @@ export function setUserAgent(): void {
export async function cleanupAzCLIAccounts(): Promise<void> {
let azPath = await io.which("az", true);
if (!azPath) {
throw new Error("Azure CLI is not found in the runner.");
}
core.debug(`Azure CLI path: ${azPath}`);
core.info("Clearing azure cli accounts from the local cache.");
await exec.exec(`"${azPath}"`, ["account", "clear"]);
@ -23,9 +20,6 @@ export async function cleanupAzCLIAccounts(): Promise<void> {
export async function cleanupAzPSAccounts(): Promise<void> {
let psPath: string = await io.which(AzPSConstants.PowerShell_CmdName, true);
if (!psPath) {
throw new Error("PowerShell is not found in the runner.");
}
core.debug(`PowerShell path: ${psPath}`);
core.debug("Importing Azure PowerShell module.");
AzPSUtils.setPSModulePathForGitHubRunner();