From b3cb787c62e91c0e6b8f0b29af1eb4e2c2457af7 Mon Sep 17 00:00:00 2001 From: Aishwarya Bhandari Date: Fri, 14 Nov 2025 12:17:25 -0800 Subject: [PATCH 1/7] Fixing download latest from feed script setting nightly build to true for testing fixing script to see if it works fixing syntax switching back to using nightly build conditional param --- .../steps/download-latest-from-feed.yml | 37 +++++++++++++++---- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/eng/ci/templates/official/steps/download-latest-from-feed.yml b/eng/ci/templates/official/steps/download-latest-from-feed.yml index 3823ae0d4..16911a3dd 100644 --- a/eng/ci/templates/official/steps/download-latest-from-feed.yml +++ b/eng/ci/templates/official/steps/download-latest-from-feed.yml @@ -14,14 +14,35 @@ steps: script: | # Fetch the latest version of the func-cli package from the feed. All packages should have the # same package version as it is based on the CLI version + build number (which is date based) - $packageUrl = "https://feeds.dev.azure.com/azfunc/internal/_apis/packaging/feeds/core-tools-nightly-build/packages/a998de77-f16c-4c10-af8c-cfa5a430eae7?api-version=7.1" $headers = @{ Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN" } - $response = Invoke-RestMethod -Uri $packageUrl -Headers $headers -Method Get - $latestVersion = $response.versions[0].version - - Write-Host "##vso[task.setvariable variable=FUNC_CLI_VERSION]$latestVersion" - Write-Host "Using func-cli version: $latestVersion" + function Get-LatestPackageVersion { + param($packageName) + + $searchUrl = "https://feeds.dev.azure.com/azfunc/internal/_apis/packaging/feeds/core-tools-nightly-build/packages?packageNameQuery=$packageName&api-version=7.1" + $searchResponse = Invoke-RestMethod -Uri $searchUrl -Headers $headers -Method Get + $package = $searchResponse.value | Where-Object { $_.name -eq $packageName } | Select-Object -First 1 + + if ($package) { + $packageUrl = "https://feeds.dev.azure.com/azfunc/internal/_apis/packaging/feeds/core-tools-nightly-build/packages/$($package.id)?api-version=7.1" + $packageDetails = Invoke-RestMethod -Uri $packageUrl -Headers $headers -Method Get + return $packageDetails.versions[0].version + } + return $null + } + + # Get version for each package + $funcCliVersion = Get-LatestPackageVersion -packageName "func-cli" + Write-Host "##vso[task.setvariable variable=FUNC_CLI_VERSION]$funcCliVersion" + Write-Host "func-cli version: $funcCliVersion" + + $funcCliInprocVersion = Get-LatestPackageVersion -packageName "func-cli-inproc" + Write-Host "##vso[task.setvariable variable=FUNC_CLI_INPROC_VERSION]$funcCliInprocVersion" + Write-Host "func-cli-inproc version: $funcCliInprocVersion" + + $funcCliHostVersion = Get-LatestPackageVersion -packageName "func-cli-host" + Write-Host "##vso[task.setvariable variable=FUNC_CLI_HOST_VERSION]$funcCliHostVersion" + Write-Host "func-cli-host version: $funcCliHostVersion" env: SYSTEM_ACCESSTOKEN: $(System.AccessToken) @@ -41,7 +62,7 @@ steps: packageType: 'upack' feed: 'internal/core-tools-nightly-build' definition: 'func-cli-inproc' - version: '$(FUNC_CLI_VERSION)' + version: '$(FUNC_CLI_INPROC_VERSION)' downloadPath: '$(Pipeline.Workspace)/func-cli-inproc' - task: DownloadPackage@1 @@ -50,5 +71,5 @@ steps: packageType: 'upack' feed: 'internal/core-tools-nightly-build' definition: 'func-cli-host' - version: '$(FUNC_CLI_VERSION)' + version: '$(FUNC_CLI_HOST_VERSION)' downloadPath: '$(Pipeline.Workspace)/func-cli-host' From ba83e117ec94afe2e704d75581e01b97900ba68f Mon Sep 17 00:00:00 2001 From: Aishwarya Bhandari Date: Fri, 14 Nov 2025 12:48:42 -0800 Subject: [PATCH 2/7] updating comment --- eng/ci/templates/official/steps/download-latest-from-feed.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/eng/ci/templates/official/steps/download-latest-from-feed.yml b/eng/ci/templates/official/steps/download-latest-from-feed.yml index 16911a3dd..9e662fed9 100644 --- a/eng/ci/templates/official/steps/download-latest-from-feed.yml +++ b/eng/ci/templates/official/steps/download-latest-from-feed.yml @@ -12,8 +12,7 @@ steps: inputs: targetType: 'inline' script: | - # Fetch the latest version of the func-cli package from the feed. All packages should have the - # same package version as it is based on the CLI version + build number (which is date based) + # Fetch the latest version of the func-cli package from the feed for each package $headers = @{ Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN" } function Get-LatestPackageVersion { From 6d6226bdeba614ca03c2545a16225c00e7551235 Mon Sep 17 00:00:00 2001 From: Aishwarya Bhandari Date: Fri, 14 Nov 2025 16:32:28 -0800 Subject: [PATCH 3/7] addressing comments --- .../steps/download-latest-from-feed.yml | 26 ++++--------------- eng/scripts/get-latest-package-version.ps1 | 25 ++++++++++++++++++ 2 files changed, 30 insertions(+), 21 deletions(-) create mode 100644 eng/scripts/get-latest-package-version.ps1 diff --git a/eng/ci/templates/official/steps/download-latest-from-feed.yml b/eng/ci/templates/official/steps/download-latest-from-feed.yml index 9e662fed9..cd2f37f44 100644 --- a/eng/ci/templates/official/steps/download-latest-from-feed.yml +++ b/eng/ci/templates/official/steps/download-latest-from-feed.yml @@ -15,33 +15,17 @@ steps: # Fetch the latest version of the func-cli package from the feed for each package $headers = @{ Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN" } - function Get-LatestPackageVersion { - param($packageName) - - $searchUrl = "https://feeds.dev.azure.com/azfunc/internal/_apis/packaging/feeds/core-tools-nightly-build/packages?packageNameQuery=$packageName&api-version=7.1" - $searchResponse = Invoke-RestMethod -Uri $searchUrl -Headers $headers -Method Get - $package = $searchResponse.value | Where-Object { $_.name -eq $packageName } | Select-Object -First 1 - - if ($package) { - $packageUrl = "https://feeds.dev.azure.com/azfunc/internal/_apis/packaging/feeds/core-tools-nightly-build/packages/$($package.id)?api-version=7.1" - $packageDetails = Invoke-RestMethod -Uri $packageUrl -Headers $headers -Method Get - return $packageDetails.versions[0].version - } - return $null - } + # Import the function from the script + . "$(Build.SourcesDirectory)/eng/scripts/get-latest-package-version.ps1" # Get version for each package - $funcCliVersion = Get-LatestPackageVersion -packageName "func-cli" + $funcCliVersion = Get-LatestPackageVersion -packageName "func-cli" -headers $headers Write-Host "##vso[task.setvariable variable=FUNC_CLI_VERSION]$funcCliVersion" Write-Host "func-cli version: $funcCliVersion" - $funcCliInprocVersion = Get-LatestPackageVersion -packageName "func-cli-inproc" + $funcCliInprocVersion = Get-LatestPackageVersion -packageName "func-cli-inproc" -headers $headers Write-Host "##vso[task.setvariable variable=FUNC_CLI_INPROC_VERSION]$funcCliInprocVersion" Write-Host "func-cli-inproc version: $funcCliInprocVersion" - - $funcCliHostVersion = Get-LatestPackageVersion -packageName "func-cli-host" - Write-Host "##vso[task.setvariable variable=FUNC_CLI_HOST_VERSION]$funcCliHostVersion" - Write-Host "func-cli-host version: $funcCliHostVersion" env: SYSTEM_ACCESSTOKEN: $(System.AccessToken) @@ -70,5 +54,5 @@ steps: packageType: 'upack' feed: 'internal/core-tools-nightly-build' definition: 'func-cli-host' - version: '$(FUNC_CLI_HOST_VERSION)' + version: '$(FUNC_CLI_VERSION)' downloadPath: '$(Pipeline.Workspace)/func-cli-host' diff --git a/eng/scripts/get-latest-package-version.ps1 b/eng/scripts/get-latest-package-version.ps1 new file mode 100644 index 000000000..6f53c5682 --- /dev/null +++ b/eng/scripts/get-latest-package-version.ps1 @@ -0,0 +1,25 @@ +function Get-LatestPackageVersion { + param( + [Parameter(Mandatory = $true)] + [string]$packageName, + + [Parameter(Mandatory = $true)] + [hashtable]$headers + ) + + $feedUrl = "https://feeds.dev.azure.com/azfunc/internal/_apis/packaging/feeds/core-tools-nightly-build/packages" + $apiVersion = "7.1" + + $searchUrl = "$feedUrl?packageNameQuery=$packageName&api-version=$apiVersion" + $searchResponse = Invoke-RestMethod -Uri $searchUrl -Headers $headers -Method Get + $package = $searchResponse.value | Where-Object { $_.name -eq $packageName } | Select-Object -First 1 + + if (!$package) { + Write-Warning "Package '$packageName' not found in the feed." + return $null + } + + $packageUrl = "$feedUrl/$($package.id)?api-version=$apiVersion" + $packageDetails = Invoke-RestMethod -Uri $packageUrl -Headers $headers -Method Get + return $packageDetails.versions[0].version +} From c22d0fdbd261a57c8d27bee6a3d7974198d6833d Mon Sep 17 00:00:00 2001 From: Aishwarya Bhandari Date: Fri, 14 Nov 2025 16:34:14 -0800 Subject: [PATCH 4/7] testing out nightly build --- eng/ci/consolidate-artifacts-build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/ci/consolidate-artifacts-build.yml b/eng/ci/consolidate-artifacts-build.yml index d683ad74c..168dce0a0 100644 --- a/eng/ci/consolidate-artifacts-build.yml +++ b/eng/ci/consolidate-artifacts-build.yml @@ -78,14 +78,14 @@ extends: jobs: - template: /eng/ci/templates/official/jobs/download-cli-nuget-package.yml@self parameters: - isNightlyBuild: ${{ eq(variables['Build.Reason'], 'Schedule') }} + isNightlyBuild: true - ${{ each runtime in split(variables.supportedRuntimes,',') }}: - template: /eng/ci/templates/official/jobs/consolidate-cli-artifacts.yml@self parameters: arch: ${{ runtime }} displayName: ${{ replace(replace(runtime, '-', ''), '.', '') }} - isNightlyBuild: ${{ eq(variables['Build.Reason'], 'Schedule') }} + isNightlyBuild: true - stage: TestArtifacts dependsOn: 'ConsolidateArticacts' From 65bc3eca9dc01025a697e52371ee97c2075a02e9 Mon Sep 17 00:00:00 2001 From: Aishwarya Bhandari Date: Fri, 14 Nov 2025 16:45:07 -0800 Subject: [PATCH 5/7] adding debugging logs --- eng/ci/templates/official/steps/download-latest-from-feed.yml | 4 +++- eng/scripts/get-latest-package-version.ps1 | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/eng/ci/templates/official/steps/download-latest-from-feed.yml b/eng/ci/templates/official/steps/download-latest-from-feed.yml index cd2f37f44..87280f34e 100644 --- a/eng/ci/templates/official/steps/download-latest-from-feed.yml +++ b/eng/ci/templates/official/steps/download-latest-from-feed.yml @@ -16,7 +16,9 @@ steps: $headers = @{ Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN" } # Import the function from the script - . "$(Build.SourcesDirectory)/eng/scripts/get-latest-package-version.ps1" + $scriptPath = "$(Build.SourcesDirectory)/eng/scripts/get-latest-package-version.ps1" + Write-Host "Loading script from: $scriptPath" + . $scriptPath # Get version for each package $funcCliVersion = Get-LatestPackageVersion -packageName "func-cli" -headers $headers diff --git a/eng/scripts/get-latest-package-version.ps1 b/eng/scripts/get-latest-package-version.ps1 index 6f53c5682..0592899d7 100644 --- a/eng/scripts/get-latest-package-version.ps1 +++ b/eng/scripts/get-latest-package-version.ps1 @@ -7,10 +7,14 @@ function Get-LatestPackageVersion { [hashtable]$headers ) + Write-Host "Fetching package: $packageName" + $feedUrl = "https://feeds.dev.azure.com/azfunc/internal/_apis/packaging/feeds/core-tools-nightly-build/packages" $apiVersion = "7.1" $searchUrl = "$feedUrl?packageNameQuery=$packageName&api-version=$apiVersion" + Write-Host "Search URL: $searchUrl" + $searchResponse = Invoke-RestMethod -Uri $searchUrl -Headers $headers -Method Get $package = $searchResponse.value | Where-Object { $_.name -eq $packageName } | Select-Object -First 1 From 8be0fa0bc3fedad474cc044e99403222a291f4a8 Mon Sep 17 00:00:00 2001 From: Aishwarya Bhandari Date: Thu, 20 Nov 2025 11:54:17 -0800 Subject: [PATCH 6/7] addressing PR comments --- .../steps/download-latest-from-feed.yml | 20 ++----------- eng/scripts/get-latest-package-versions.ps1 | 28 +++++++++++++++++++ 2 files changed, 30 insertions(+), 18 deletions(-) create mode 100644 eng/scripts/get-latest-package-versions.ps1 diff --git a/eng/ci/templates/official/steps/download-latest-from-feed.yml b/eng/ci/templates/official/steps/download-latest-from-feed.yml index 87280f34e..345830693 100644 --- a/eng/ci/templates/official/steps/download-latest-from-feed.yml +++ b/eng/ci/templates/official/steps/download-latest-from-feed.yml @@ -10,24 +10,8 @@ steps: - task: PowerShell@2 displayName: 'Get latest artifact version' inputs: - targetType: 'inline' - script: | - # Fetch the latest version of the func-cli package from the feed for each package - $headers = @{ Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN" } - - # Import the function from the script - $scriptPath = "$(Build.SourcesDirectory)/eng/scripts/get-latest-package-version.ps1" - Write-Host "Loading script from: $scriptPath" - . $scriptPath - - # Get version for each package - $funcCliVersion = Get-LatestPackageVersion -packageName "func-cli" -headers $headers - Write-Host "##vso[task.setvariable variable=FUNC_CLI_VERSION]$funcCliVersion" - Write-Host "func-cli version: $funcCliVersion" - - $funcCliInprocVersion = Get-LatestPackageVersion -packageName "func-cli-inproc" -headers $headers - Write-Host "##vso[task.setvariable variable=FUNC_CLI_INPROC_VERSION]$funcCliInprocVersion" - Write-Host "func-cli-inproc version: $funcCliInprocVersion" + targetType: 'filePath' + filePath: '$(Build.SourcesDirectory)/eng/scripts/get-latest-package-versions.ps1' env: SYSTEM_ACCESSTOKEN: $(System.AccessToken) diff --git a/eng/scripts/get-latest-package-versions.ps1 b/eng/scripts/get-latest-package-versions.ps1 new file mode 100644 index 000000000..180b5c152 --- /dev/null +++ b/eng/scripts/get-latest-package-versions.ps1 @@ -0,0 +1,28 @@ +# Fetch the latest version of the func-cli package from the feed for each package +$headers = @{ Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN" } + +function Get-LatestPackageVersion { + param($packageName) + + $baseUrl = "https://feeds.dev.azure.com/azfunc/internal/_apis/packaging/feeds/core-tools-nightly-build" + + $searchUrl = "$baseUrl/packages?packageNameQuery=$packageName&api-version=7.1" + $searchResponse = Invoke-RestMethod -Uri $searchUrl -Headers $headers -Method Get + $package = $searchResponse.value | Where-Object { $_.name -eq $packageName } | Select-Object -First 1 + + if ($package) { + $packageUrl = "$baseUrl/packages/$($package.id)?api-version=7.1" + $packageDetails = Invoke-RestMethod -Uri $packageUrl -Headers $headers -Method Get + return $packageDetails.versions[0].version + } + return $null +} + +# Get version for each package +$funcCliVersion = Get-LatestPackageVersion -packageName "func-cli" +Write-Host "##vso[task.setvariable variable=FUNC_CLI_VERSION]$funcCliVersion" +Write-Host "func-cli version: $funcCliVersion" + +$funcCliInprocVersion = Get-LatestPackageVersion -packageName "func-cli-inproc" +Write-Host "##vso[task.setvariable variable=FUNC_CLI_INPROC_VERSION]$funcCliInprocVersion" +Write-Host "func-cli-inproc version: $funcCliInprocVersion" From a327858200906c1d9dd4a1b60ca1c677d13e0a1f Mon Sep 17 00:00:00 2001 From: Aishwarya Bhandari Date: Thu, 20 Nov 2025 13:21:32 -0800 Subject: [PATCH 7/7] changing nightly builds back to normal --- eng/ci/consolidate-artifacts-build.yml | 4 +-- eng/scripts/get-latest-package-version.ps1 | 29 ---------------------- 2 files changed, 2 insertions(+), 31 deletions(-) delete mode 100644 eng/scripts/get-latest-package-version.ps1 diff --git a/eng/ci/consolidate-artifacts-build.yml b/eng/ci/consolidate-artifacts-build.yml index 168dce0a0..d683ad74c 100644 --- a/eng/ci/consolidate-artifacts-build.yml +++ b/eng/ci/consolidate-artifacts-build.yml @@ -78,14 +78,14 @@ extends: jobs: - template: /eng/ci/templates/official/jobs/download-cli-nuget-package.yml@self parameters: - isNightlyBuild: true + isNightlyBuild: ${{ eq(variables['Build.Reason'], 'Schedule') }} - ${{ each runtime in split(variables.supportedRuntimes,',') }}: - template: /eng/ci/templates/official/jobs/consolidate-cli-artifacts.yml@self parameters: arch: ${{ runtime }} displayName: ${{ replace(replace(runtime, '-', ''), '.', '') }} - isNightlyBuild: true + isNightlyBuild: ${{ eq(variables['Build.Reason'], 'Schedule') }} - stage: TestArtifacts dependsOn: 'ConsolidateArticacts' diff --git a/eng/scripts/get-latest-package-version.ps1 b/eng/scripts/get-latest-package-version.ps1 deleted file mode 100644 index 0592899d7..000000000 --- a/eng/scripts/get-latest-package-version.ps1 +++ /dev/null @@ -1,29 +0,0 @@ -function Get-LatestPackageVersion { - param( - [Parameter(Mandatory = $true)] - [string]$packageName, - - [Parameter(Mandatory = $true)] - [hashtable]$headers - ) - - Write-Host "Fetching package: $packageName" - - $feedUrl = "https://feeds.dev.azure.com/azfunc/internal/_apis/packaging/feeds/core-tools-nightly-build/packages" - $apiVersion = "7.1" - - $searchUrl = "$feedUrl?packageNameQuery=$packageName&api-version=$apiVersion" - Write-Host "Search URL: $searchUrl" - - $searchResponse = Invoke-RestMethod -Uri $searchUrl -Headers $headers -Method Get - $package = $searchResponse.value | Where-Object { $_.name -eq $packageName } | Select-Object -First 1 - - if (!$package) { - Write-Warning "Package '$packageName' not found in the feed." - return $null - } - - $packageUrl = "$feedUrl/$($package.id)?api-version=$apiVersion" - $packageDetails = Invoke-RestMethod -Uri $packageUrl -Headers $headers -Method Get - return $packageDetails.versions[0].version -}