Skip to content

Commit be77bf4

Browse files
committed
Add pipeline parameters to build azure-functions-java-additions from source
The worker depends on `azure-functions-java-core-library:1.4.0-SNAPSHOT` during development of cross-repo changes, but ADO CI agents only resolve from Maven Central + OSS Sonatype snapshots. There was no way to validate a worker PR against a fork/branch of azure-functions-java-additions without first publishing the snapshot. This adds three opt-in pipeline parameters to `public-build.yml`: - buildAdditionsFromSource (bool, default: false) - additionsRepoUrl (string, default: official Azure repo) - additionsBranch (string, default: dev) When the toggle is true, an "Install azure-functions-java-additions from source" step runs before the worker's mvn build in every job (Build, TestWindows, TestLinux, TestDocker). The step delegates to the existing `installAdditionsLocally.ps1`, which is parameterized to accept a repo URL + branch and made idempotent for CI re-runs. When the toggle is false (the default for normal PRs against dev) the step is excluded at template-expansion time via `${{ if eq(...) }}`, so there is zero impact on existing builds. To use: queue the PR pipeline manually from the ADO UI, check "Build azure-functions-java-additions from source", and optionally override the repo URL/branch to point at a fork (e.g. `https://github.com/ahmedmuhsin/azure-functions-java-additions.git` on `feat/http-response-bodystream`).
1 parent 5614458 commit be77bf4

6 files changed

Lines changed: 131 additions & 23 deletions

File tree

eng/ci/public-build.yml

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,24 @@ pr:
1717
include:
1818
- dev
1919

20+
# Pipeline-level parameters surfaced in the ADO "Run pipeline" dialog so we can
21+
# build a custom branch of azure-functions-java-additions (e.g. a fork) before
22+
# the worker's mvn build. Defaults to a no-op so normal PRs continue to resolve
23+
# the library from Maven Central.
24+
parameters:
25+
- name: buildAdditionsFromSource
26+
displayName: 'Build azure-functions-java-additions from source (instead of resolving from Maven Central)'
27+
type: boolean
28+
default: false
29+
- name: additionsRepoUrl
30+
displayName: 'Git URL for azure-functions-java-additions (used only when buildAdditionsFromSource is true)'
31+
type: string
32+
default: 'https://github.com/Azure/azure-functions-java-additions.git'
33+
- name: additionsBranch
34+
displayName: 'Branch of azure-functions-java-additions to build (used only when buildAdditionsFromSource is true)'
35+
type: string
36+
default: 'dev'
37+
2038
resources:
2139
repositories:
2240
- repository: 1es
@@ -51,24 +69,37 @@ extends:
5169
- stage: Build
5270
jobs:
5371
- template: /eng/ci/templates/jobs/build.yml@self
72+
parameters:
73+
buildAdditionsFromSource: ${{ parameters.buildAdditionsFromSource }}
74+
additionsRepoUrl: ${{ parameters.additionsRepoUrl }}
75+
additionsBranch: ${{ parameters.additionsBranch }}
5476

5577
- stage: TestWindows
5678
dependsOn: []
5779
jobs:
5880
- template: /eng/ci/templates/jobs/run-emulated-tests-windows.yml@self
5981
parameters:
6082
poolName: 1es-pool-azfunc-public
83+
buildAdditionsFromSource: ${{ parameters.buildAdditionsFromSource }}
84+
additionsRepoUrl: ${{ parameters.additionsRepoUrl }}
85+
additionsBranch: ${{ parameters.additionsBranch }}
6186

6287
- stage: TestLinux
6388
dependsOn: []
6489
jobs:
6590
- template: /eng/ci/templates/jobs/run-emulated-tests-linux.yml@self
6691
parameters:
6792
poolName: 1es-pool-azfunc-public
93+
buildAdditionsFromSource: ${{ parameters.buildAdditionsFromSource }}
94+
additionsRepoUrl: ${{ parameters.additionsRepoUrl }}
95+
additionsBranch: ${{ parameters.additionsBranch }}
6896

6997
- stage: TestDocker
7098
dependsOn: []
7199
jobs:
72100
- template: /eng/ci/templates/jobs/run-docker-tests-linux.yml@self
73101
parameters:
74-
poolName: 1es-pool-azfunc-public
102+
poolName: 1es-pool-azfunc-public
103+
buildAdditionsFromSource: ${{ parameters.buildAdditionsFromSource }}
104+
additionsRepoUrl: ${{ parameters.additionsRepoUrl }}
105+
additionsBranch: ${{ parameters.additionsBranch }}

eng/ci/templates/jobs/build.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
parameters:
2+
- name: buildAdditionsFromSource
3+
type: boolean
4+
default: false
5+
- name: additionsRepoUrl
6+
type: string
7+
default: 'https://github.com/Azure/azure-functions-java-additions.git'
8+
- name: additionsBranch
9+
type: string
10+
default: 'dev'
11+
112
jobs:
213
- job: "Build"
314
displayName: 'Build java worker'
@@ -14,6 +25,10 @@ jobs:
1425
- pwsh: |
1526
java -version
1627
displayName: 'Check default java version'
28+
- ${{ if eq(parameters.buildAdditionsFromSource, true) }}:
29+
- pwsh: |
30+
./installAdditionsLocally.ps1 -AdditionsRepoUrl '${{ parameters.additionsRepoUrl }}' -AdditionsBranch '${{ parameters.additionsBranch }}'
31+
displayName: 'Install azure-functions-java-additions from source'
1732
- pwsh: |
1833
mvn clean package
1934
displayName: 'Build java worker'

eng/ci/templates/jobs/run-docker-tests-linux.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@ parameters:
22
- name: poolName
33
type: string
44
default: ''
5+
- name: buildAdditionsFromSource
6+
type: boolean
7+
default: false
8+
- name: additionsRepoUrl
9+
type: string
10+
default: 'https://github.com/Azure/azure-functions-java-additions.git'
11+
- name: additionsBranch
12+
type: string
13+
default: 'dev'
514

615
jobs:
716
- job: "TestDocker"
@@ -51,6 +60,11 @@ jobs:
5160
pip install -e dockertests/azure-functions-test-kit
5261
displayName: 'Install Python dependencies'
5362
63+
- ${{ if eq(parameters.buildAdditionsFromSource, true) }}:
64+
- pwsh: |
65+
./installAdditionsLocally.ps1 -AdditionsRepoUrl '${{ parameters.additionsRepoUrl }}' -AdditionsBranch '${{ parameters.additionsBranch }}'
66+
displayName: 'Install azure-functions-java-additions from source'
67+
5468
- pwsh: |
5569
./package-pipeline.ps1 -outputDir 'java-worker' -skipNuget
5670
displayName: 'Package Java worker'

eng/ci/templates/jobs/run-emulated-tests-linux.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@ parameters:
22
- name: poolName
33
type: string
44
default: ''
5+
- name: buildAdditionsFromSource
6+
type: boolean
7+
default: false
8+
- name: additionsRepoUrl
9+
type: string
10+
default: 'https://github.com/Azure/azure-functions-java-additions.git'
11+
- name: additionsBranch
12+
type: string
13+
default: 'dev'
514

615
jobs:
716
- job: "TestLinux"
@@ -83,6 +92,10 @@ jobs:
8392
docker compose -f emulatedtests/utils/docker-compose.yml pull
8493
docker compose -f emulatedtests/utils/docker-compose.yml up -d
8594
displayName: 'Install Azurite and Start Emulators'
95+
- ${{ if eq(parameters.buildAdditionsFromSource, true) }}:
96+
- pwsh: |
97+
./installAdditionsLocally.ps1 -AdditionsRepoUrl '${{ parameters.additionsRepoUrl }}' -AdditionsBranch '${{ parameters.additionsBranch }}'
98+
displayName: 'Install azure-functions-java-additions from source'
8699
- pwsh: |
87100
if ("$(isTag)"){
88101
$buildNumber="$(Build.SourceBranchName)"

eng/ci/templates/jobs/run-emulated-tests-windows.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@ parameters:
22
- name: poolName
33
type: string
44
default: ''
5+
- name: buildAdditionsFromSource
6+
type: boolean
7+
default: false
8+
- name: additionsRepoUrl
9+
type: string
10+
default: 'https://github.com/Azure/azure-functions-java-additions.git'
11+
- name: additionsBranch
12+
type: string
13+
default: 'dev'
514

615
jobs:
716
- job: "TestWindows"
@@ -78,6 +87,10 @@ jobs:
7887
mkdir azurite
7988
azurite --silent --location azurite --debug azurite\debug.log &
8089
displayName: 'Install and Run Azurite'
90+
- ${{ if eq(parameters.buildAdditionsFromSource, true) }}:
91+
- pwsh: |
92+
./installAdditionsLocally.ps1 -AdditionsRepoUrl '${{ parameters.additionsRepoUrl }}' -AdditionsBranch '${{ parameters.additionsBranch }}'
93+
displayName: 'Install azure-functions-java-additions from source'
8194
- pwsh: |
8295
if ("$(isTag)"){
8396
$buildNumber="$(Build.SourceBranchName)"

installAdditionsLocally.ps1

Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,50 @@
1-
# Variables for first repository
2-
$repoUrl1 = 'https://github.com/Azure/azure-functions-java-additions.git'
3-
$branchName1 = 'dev'
4-
$repoName1 = 'azure-functions-java-additions'
1+
[CmdletBinding()]
2+
param(
3+
[string]$AdditionsRepoUrl = 'https://github.com/Azure/azure-functions-java-additions.git',
4+
[string]$AdditionsBranch = 'dev'
5+
)
56

6-
# Clone the first repository
7-
git clone $repoUrl1
7+
$ErrorActionPreference = 'Stop'
88

9-
# Change directory to the cloned repository
10-
Set-Location $repoName1
9+
$repoName = 'azure-functions-java-additions'
10+
$workerRoot = $PSScriptRoot
11+
$cloneDir = Join-Path $workerRoot $repoName
12+
$mvnBuildScript = Join-Path $workerRoot 'mvnBuildAdditions.bat'
1113

12-
# Checkout the desired branch
13-
git checkout $branchName1
14+
Write-Host "Installing $repoName from $AdditionsRepoUrl (branch: $AdditionsBranch)"
15+
Write-Host "Clone destination: $cloneDir"
1416

15-
# Detect OS and execute build accordingly
16-
if ($IsWindows) {
17-
# Run the batch script (mvnBuild.bat)
18-
& "..\mvnBuildAdditions.bat"
19-
} else {
20-
# Extract and explicitly invoke the mvn command from mvnBuild.bat
21-
$mvnCommand = Get-Content "../mvnBuildAdditions.bat" | Where-Object { $_ -match '^mvn\s+' }
22-
if ($null -ne $mvnCommand) {
23-
# Execute the extracted mvn command explicitly as a single line
24-
bash -c "$mvnCommand"
25-
} else {
26-
Write-Error "No mvn command found in mvnBuild.bat."
17+
# Make the clone idempotent for re-runs.
18+
if (Test-Path $cloneDir) {
19+
Write-Host "Removing existing $cloneDir"
20+
Remove-Item -Path $cloneDir -Recurse -Force
21+
}
22+
23+
Push-Location $workerRoot
24+
try {
25+
git clone --branch $AdditionsBranch --single-branch $AdditionsRepoUrl
26+
if ($LASTEXITCODE -ne 0) { throw "git clone failed for $AdditionsRepoUrl ($AdditionsBranch)" }
27+
28+
Push-Location $repoName
29+
try {
30+
if ($IsWindows) {
31+
# Run the batch script (mvnBuildAdditions.bat)
32+
& $mvnBuildScript
33+
if ($LASTEXITCODE -ne 0) { throw "mvnBuildAdditions.bat failed" }
34+
} else {
35+
# Extract and explicitly invoke the mvn command from mvnBuildAdditions.bat
36+
$mvnCommand = Get-Content $mvnBuildScript | Where-Object { $_ -match '^mvn\s+' }
37+
if ($null -ne $mvnCommand) {
38+
# Execute the extracted mvn command explicitly as a single line
39+
bash -c "$mvnCommand"
40+
if ($LASTEXITCODE -ne 0) { throw "mvn command failed" }
41+
} else {
42+
throw "No mvn command found in $mvnBuildScript"
43+
}
44+
}
45+
} finally {
46+
Pop-Location
2747
}
48+
} finally {
49+
Pop-Location
2850
}

0 commit comments

Comments
 (0)