Skip to content

Commit b3c9ccc

Browse files
committed
consitantly use pwsh
1 parent 7e8aaa5 commit b3c9ccc

File tree

2 files changed

+31
-27
lines changed

2 files changed

+31
-27
lines changed
Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
11
steps:
2-
- bash: |
3-
RELEASE_JSON=$(curl -s "https://api.github.com/repos/microsoft/kiota/releases/latest")
4-
LATEST_TAG=$(echo "$RELEASE_JSON" | jq -r '.tag_name')
5-
ASSET_URL=$(echo "$RELEASE_JSON" | jq -r '.assets[] | select(.name | test("linux-x64")) | .browser_download_url')
6-
echo "Downloading Kiota $LATEST_TAG"
7-
echo "Asset URL: $ASSET_URL"
8-
curl -L "$ASSET_URL" -o kiota_download
9-
mkdir -p /tmp/kiota_extract
10-
if [[ "$ASSET_URL" == *.zip ]]; then
11-
unzip kiota_download -d /tmp/kiota_extract
12-
else
13-
tar -xzf kiota_download -C /tmp/kiota_extract
14-
fi
15-
KIOTA_BIN=$(find /tmp/kiota_extract -name kiota -type f | head -1)
16-
echo "Found Kiota binary at: $KIOTA_BIN"
17-
mkdir -p "$(Build.ArtifactStagingDirectory)"
18-
cp "$KIOTA_BIN" "$(Build.ArtifactStagingDirectory)/kiota"
2+
- pwsh: |
3+
$releaseJson = Invoke-RestMethod "https://api.github.com/repos/microsoft/kiota/releases/latest"
4+
$latestTag = $releaseJson.tag_name
5+
$asset = $releaseJson.assets | Where-Object { $_.name -match "linux-x64" } | Select-Object -First 1
6+
Write-Host "Downloading Kiota $latestTag"
7+
Write-Host "Asset URL: $($asset.browser_download_url)"
8+
9+
$extractDir = Join-Path ([System.IO.Path]::GetTempPath()) "kiota_extract_$([System.IO.Path]::GetRandomFileName())"
10+
New-Item -ItemType Directory -Force -Path $extractDir | Out-Null
11+
$downloadPath = Join-Path $extractDir "kiota_download.zip"
12+
13+
Invoke-WebRequest -Uri $asset.browser_download_url -OutFile $downloadPath
14+
Expand-Archive -Path $downloadPath -DestinationPath $extractDir -Force
15+
16+
Write-Host "=== Extracted contents ==="
17+
Get-ChildItem $extractDir -Recurse | Select-Object FullName
18+
19+
$kiotaBin = Get-ChildItem -Path $extractDir -Recurse -File | Where-Object { $_.BaseName -eq "kiota" } | Select-Object -First 1
20+
Write-Host "Found Kiota binary at: $($kiotaBin.FullName)"
21+
22+
New-Item -ItemType Directory -Force -Path "$(Build.ArtifactStagingDirectory)" | Out-Null
23+
Copy-Item -Path $kiotaBin.FullName -Destination (Join-Path "$(Build.ArtifactStagingDirectory)" "kiota")
1924
displayName: 'Download latest Kiota from GitHub'

.azure-pipelines/generation-templates/set-up-for-generation-kiota.yml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,16 @@ steps:
88
parameters:
99
version: "10.x"
1010

11-
- bash: |
12-
KIOTA_BIN=$(find "$(kiotaDirectory)" -name "kiota" -type f | head -1)
13-
if [ -z "$KIOTA_BIN" ]; then
14-
echo "ERROR: kiota binary not found under $(kiotaDirectory)"
15-
echo "Directory contents:"
16-
ls -laR "$(kiotaDirectory)" || echo "Directory does not exist"
11+
- pwsh: |
12+
$kiotaBin = Get-ChildItem -Path "$(kiotaDirectory)" -Recurse -File | Where-Object { $_.BaseName -eq "kiota" } | Select-Object -First 1
13+
if (-not $kiotaBin) {
14+
Write-Error "Kiota binary not found under $(kiotaDirectory)"
15+
Get-ChildItem "$(kiotaDirectory)" -Recurse -ErrorAction SilentlyContinue | Select-Object FullName
1716
exit 1
18-
fi
19-
chmod +x "$KIOTA_BIN"
20-
echo "Kiota binary ready at: $KIOTA_BIN"
21-
echo "##vso[task.setvariable variable=kiotaExecutable]$KIOTA_BIN"
17+
}
18+
chmod +x $kiotaBin.FullName
19+
Write-Host "Kiota binary ready at: $($kiotaBin.FullName)"
20+
Write-Host "##vso[task.setvariable variable=kiotaExecutable]$($kiotaBin.FullName)"
2221
displayName: 'Make Kiota executable'
2322

2423
# checkout metadata repo if capture and clean step is skipped

0 commit comments

Comments
 (0)