Skip to content

Commit

Permalink
Fix #403: Catch the error thrown in pre and post steps (#407)
Browse files Browse the repository at this point in the history
* fix #403

* modify error handling
  • Loading branch information
MoChilia authored Jan 17, 2024
1 parent 2d38cb8 commit aeb0c36
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 7 deletions.
2 changes: 1 addition & 1 deletion src/cleanup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
6 changes: 0 additions & 6 deletions src/common/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,13 @@ 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"]);
}

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();
Expand Down

0 comments on commit aeb0c36

Please sign in to comment.