mirror of
https://github.com/azure/login.git
synced 2026-03-12 18:07:08 -04:00
modify error handling
This commit is contained in:
@@ -17,9 +17,6 @@ export class AzureCliLogin {
|
||||
async login() {
|
||||
core.info(`Running Azure CLI Login.`);
|
||||
this.azPath = await io.which("az", true);
|
||||
if (!this.azPath) {
|
||||
throw new Error("Azure CLI is not found in the runner.");
|
||||
}
|
||||
core.debug(`Azure CLI path: ${this.azPath}`);
|
||||
|
||||
let output: string = "";
|
||||
|
||||
@@ -71,9 +71,6 @@ export class AzPSUtils {
|
||||
};
|
||||
|
||||
let psPath: string = await io.which(AzPSConstants.PowerShell_CmdName, true);
|
||||
if (!psPath) {
|
||||
throw new Error("PowerShell is not found in the runner.");
|
||||
}
|
||||
await exec.exec(`"${psPath}"`, ["-Command", psScript], options)
|
||||
if (commandStdErr) {
|
||||
throw new Error('Azure PowerShell login failed with errors.');
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,10 +13,6 @@ export function setUserAgent(): void {
|
||||
|
||||
export async function cleanupAzCLIAccounts(): Promise<void> {
|
||||
let azPath = await io.which("az", true);
|
||||
if (!azPath) {
|
||||
core.warning("Azure CLI is not found in the runner.");
|
||||
return;
|
||||
}
|
||||
core.debug(`Azure CLI path: ${azPath}`);
|
||||
core.info("Clearing azure cli accounts from the local cache.");
|
||||
await exec.exec(`"${azPath}"`, ["account", "clear"]);
|
||||
@@ -24,10 +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) {
|
||||
core.warning("PowerShell is not found in the runner.");
|
||||
return;
|
||||
}
|
||||
core.debug(`PowerShell path: ${psPath}`);
|
||||
core.debug("Importing Azure PowerShell module.");
|
||||
AzPSUtils.setPSModulePathForGitHubRunner();
|
||||
|
||||
Reference in New Issue
Block a user