Skip to content

Commit 8e53157

Browse files
tpavloviNemanja Rogic
andauthored
Fix the issue which caussed regression on AzurePowershell@5 (#21372)
* Fix for OpenSSL * added missing import * updated version * added logs * Try multiple imports * Remove invalid import * Import VstsSdk * Upgrade VstsTaskSdk * Remove unnecessary changes --------- Co-authored-by: Nemanja Rogic <[email protected]>
1 parent 2aec9ab commit 8e53157

File tree

6 files changed

+13
-9
lines changed

6 files changed

+13
-9
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Import-Module "$PSScriptRoot\ps_modules\VstsTaskSdk" -ArgumentList @{ NonInteractive = $true }

Tasks/AzurePowerShellV5/RemoveAzContext.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
Import-Module "$PSScriptRoot\ps_modules\VstsTaskSdk" -ArgumentList @{ NonInteractive = $true }
2+
13
. "$PSScriptRoot/Utility.ps1"
24
. "$PSScriptRoot/ps_modules/VstsAzureHelpers_/Utility.ps1"
35

Tasks/AzurePowerShellV5/azurepowershell.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ async function run() {
1919

2020
const env = process.env;
2121
const hostEnv = `ADO/AzurePowerShell@v5_${env.AGENT_OS || ""}_${env.AGENT_NAME || ""}_${env.BUILD_DEFINITIONNAME || ""}_${env.BUILD_BUILDID || ""}_${env.RELEASE_DEFINITIONNAME || ""}_${env.RELEASE_RELEASEID || ""}`;
22-
22+
2323
process.env.AZUREPS_HOST_ENVIRONMENT = hostEnv;
24-
console.log(`AZUREPS_HOST_ENVIRONMENT: ${hostEnv}`);
24+
console.log(`AZUREPS_HOST_ENVIRONMENT: ${hostEnv}`);
2525

2626
try {
2727
tl.setResourcePath(path.join(__dirname, 'task.json'));
@@ -137,14 +137,15 @@ async function run() {
137137
//
138138
// Note, use "-Command" instead of "-File" to match the Windows implementation. Refer to
139139
// comment on Windows implementation for an explanation why "-Command" is preferred.
140+
const importSdk = path.join(path.resolve(__dirname), 'ImportVstsTaskSdk.ps1');
140141
let powershell = tl.tool(tl.which('pwsh') || tl.which('powershell') || tl.which('pwsh', true))
141142
.arg('-NoLogo')
142143
.arg('-NoProfile')
143144
.arg('-NonInteractive')
144145
.arg('-ExecutionPolicy')
145146
.arg('Unrestricted')
146147
.arg('-Command')
147-
.arg(`. '${filePath.replace(/'/g, "''")}'`);
148+
.arg(`. '${importSdk}'; . '${filePath.replace(/'/g, "''")}'`);
148149

149150
let options = <tr.IExecOptions>{
150151
cwd: input_workingDirectory,
@@ -187,7 +188,7 @@ async function run() {
187188
.arg('-ExecutionPolicy')
188189
.arg('Unrestricted')
189190
.arg('-Command')
190-
.arg(`. '${path.join(path.resolve(__dirname),'RemoveAzContext.ps1')}'`);
191+
.arg(`. '${path.join(path.resolve(__dirname), 'RemoveAzContext.ps1')}'`);
191192

192193
let options = <tr.IExecOptions>{
193194
cwd: input_workingDirectory,
@@ -207,7 +208,7 @@ async function run() {
207208
async function getInstalledAzModuleVersion(): Promise<string | null> {
208209
try {
209210
tl.debug('Checking installed Az PowerShell module version...');
210-
211+
211212
// PowerShell command to get the installed Az module version
212213
const powershell = tl.tool(tl.which('pwsh') || tl.which('powershell') || tl.which('pwsh', true))
213214
.arg('-NoLogo')
@@ -217,7 +218,7 @@ async function getInstalledAzModuleVersion(): Promise<string | null> {
217218
.arg('Unrestricted')
218219
.arg('-Command')
219220
.arg(`. '${path.join(path.resolve(__dirname),'Utility.ps1')}'; Get-InstalledMajorRelease -moduleName 'Az' -iswin $false`);
220-
221+
221222
const result = await powershell.execSync()
222223
if (result.code === 0 && result.stdout) {
223224
const version = result.stdout.trim();

Tasks/AzurePowerShellV5/make.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"nugetv2": [
2424
{
2525
"name": "VstsTaskSdk",
26-
"version": "0.20.1",
26+
"version": "0.21.0",
2727
"repository": "https://www.powershellgallery.com/api/v2/",
2828
"cp": [
2929
{

Tasks/AzurePowerShellV5/task.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"author": "Microsoft Corporation",
1818
"version": {
1919
"Major": 5,
20-
"Minor": 263,
20+
"Minor": 264,
2121
"Patch": 0
2222
},
2323
"releaseNotes": "Added support for Az Module and cross platform agents.",

Tasks/AzurePowerShellV5/task.loc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"author": "Microsoft Corporation",
1818
"version": {
1919
"Major": 5,
20-
"Minor": 263,
20+
"Minor": 264,
2121
"Patch": 0
2222
},
2323
"releaseNotes": "ms-resource:loc.releaseNotes",

0 commit comments

Comments
 (0)