This commit is contained in:
MoChilia
2024-01-16 17:51:00 +08:00
parent 2d38cb8921
commit 1e4938326b
3 changed files with 10 additions and 2 deletions

View File

@@ -17,6 +17,9 @@ 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 = "";

View File

@@ -71,6 +71,9 @@ 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.');

View File

@@ -14,7 +14,8 @@ 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.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.");
@@ -24,7 +25,8 @@ 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.warning("PowerShell is not found in the runner.");
return;
}
core.debug(`PowerShell path: ${psPath}`);
core.debug("Importing Azure PowerShell module.");