azure-functions-java-worker/azure-pipelines.yml

259 строки
10 KiB
YAML

# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
trigger:
tags:
include:
- '*'
branches:
include:
- dev
- v3.x
- release/3.x
- release/main
pr:
branches:
include:
- dev
- v3.x
- release/3.x
- release/main
jobs:
- job: "Build"
displayName: 'Build java worker'
pool:
name: '1ES-Hosted-AzFunc'
demands:
- ImageOverride -equals MMS2019TLS
variables:
${{ if contains(variables['Build.SourceBranch'], '/tags/' ) }}:
isTagTemp: true
isTag: $[variables.isTagTemp]
steps:
- task: NuGetToolInstaller@1
inputs:
checkLatest: true
displayName: 'Install NuGet Tool'
- pwsh: |
Get-Command mvn
displayName: 'Check Maven is installed'
- pwsh: |
java -version
displayName: 'Check default java version'
- pwsh: |
if ("$(isTag)"){
$buildNumber="$(Build.SourceBranchName)"
Write-Host "Found git tag."
}
else {
$buildNumber="$(Build.BuildNumber)-v4"
Write-Host "git tag not found. Setting package suffix to '$buildNumber'"
}
Write-Host "##vso[task.setvariable variable=buildNumber;isOutput=true;]$buildNumber"
.\package-pipeline.ps1 -buildNumber $buildNumber
name: output
displayName: 'Executing build script'
- task: CopyFiles@2
inputs:
SourceFolder: '$(Build.Repository.LocalPath)/pkg'
Contents: '*.nupkg'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
CleanTargetFolder: true
displayName: 'Copying files for artifacts'
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'buildDrop'
displayName: 'Upload build artifacts'
- job: "Test"
displayName: 'Test java worker'
dependsOn: Build
variables:
buildNumber: $[ dependencies.Build.outputs['output.buildNumber'] ]
strategy:
maxParallel: 1
matrix:
open-jdk-8-linux:
IMAGE_TYPE: 'ubuntu-latest'
JDK_DOWNLOAD_LINK: 'https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u322-b06/OpenJDK8U-jdk_x64_linux_hotspot_8u322b06.tar.gz'
JAVA_VERSION: 'OpenJDK8U-jdk_x64_windows_hotspot_8u322b06'
JDK_PATH: 'jdk8u322-b06'
JAVA_VERSION_SPEC: '8'
open-jdk-8-windows:
IMAGE_TYPE: 'windows-latest'
JDK_DOWNLOAD_LINK: 'https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u322-b06/OpenJDK8U-jdk_x64_windows_hotspot_8u322b06.zip'
JAVA_VERSION: 'OpenJDK8U-jdk_x64_windows_hotspot_8u322b06'
JDK_PATH: 'jdk8u322-b06'
microsoft-open-jdk-11-linux:
IMAGE_TYPE: 'ubuntu-latest'
JDK_DOWNLOAD_LINK: 'https://aka.ms/download-jdk/microsoft-jdk-11.0.13.8.1-linux-x64.tar.gz'
JAVA_VERSION: 'microsoft-jdk-11.0.13.8.1-linux-x64'
JDK_PATH: 'jdk-11.0.13+8'
JAVA_VERSION_SPEC: '11'
microsoft-open-jdk-11-windows:
IMAGE_TYPE: 'windows-latest'
JDK_DOWNLOAD_LINK: 'https://aka.ms/download-jdk/microsoft-jdk-11.0.13.8.1-windows-x64.zip'
JAVA_VERSION: 'microsoft-jdk-11.0.13.8.1-windows-x64'
JDK_PATH: 'jdk-11.0.13+8'
microsoft-open-jdk-17-linux:
IMAGE_TYPE: 'ubuntu-latest'
JDK_DOWNLOAD_LINK: 'https://aka.ms/download-jdk/microsoft-jdk-17.0.3-linux-x64.tar.gz'
JAVA_VERSION: 'microsoft-jdk-17.0.3-linux-x64'
JDK_PATH: 'jdk-17.0.3+7'
JAVA_VERSION_SPEC: '17'
microsoft-open-jdk-17-windows:
IMAGE_TYPE: 'windows-latest'
JDK_DOWNLOAD_LINK: 'https://aka.ms/download-jdk/microsoft-jdk-17.0.3-windows-x64.zip'
JAVA_VERSION: 'microsoft-jdk-17.0.3-windows-x64'
JDK_PATH: 'jdk-17.0.3+7'
pool:
vmImage: $(IMAGE_TYPE)
steps:
- task: NuGetToolInstaller@1
inputs:
checkLatest: true
displayName: 'Install NuGet Tool'
- pwsh: |
Get-Command mvn
displayName: 'Check Maven is installed'
- task: JavaToolInstaller@0 # This step is necessary as Linux image has Java 11 as default
inputs:
versionSpec: '8'
jdkArchitectureOption: 'x64'
jdkSourceOption: 'PreInstalled'
condition: eq( variables['Agent.OS'], 'Linux' )
displayName: 'Setup Java for Linux'
- pwsh: |
java -version
displayName: 'Check default java version'
- pwsh: |
.\package-pipeline.ps1 -buildNumber $(buildNumber)
displayName: 'Executing build script'
- task: UseDotNet@2
displayName: 'Install .NET 6'
inputs:
version: 6.0.x
- pwsh: | # Download JDK for later installation
Invoke-WebRequest $(JDK_DOWNLOAD_LINK) -O "$(JAVA_VERSION).tar.gz"
$current = get-location | select -ExpandProperty Path
Write-Host "##vso[task.setvariable variable=downloadPath;]$current"
displayName: 'Download jdk for Linux'
condition: eq( variables['Agent.OS'], 'Linux' )
- task: JavaToolInstaller@0 # Install JDK downloaded from previous task
inputs:
versionSpec: $(JAVA_VERSION_SPEC)
jdkArchitectureOption: 'x64'
jdkSourceOption: LocalDirectory
jdkFile: "$(downloadPath)/$(JAVA_VERSION).tar.gz"
jdkDestinationDirectory: "$(downloadPath)/externals"
cleanDestinationDirectory: true
condition: eq( variables['Agent.OS'], 'Linux' )
displayName: 'Setup Java for Linux'
- pwsh: |
Invoke-WebRequest $(JDK_DOWNLOAD_LINK) -O "$(JAVA_VERSION).zip"
Expand-Archive -Force "$(JAVA_VERSION).zip" .
cd $(JDK_PATH)
$current = get-location | select -ExpandProperty Path
cd ..
Write-Host "##vso[task.setvariable variable=JavaHome;]$current"
displayName: 'Download and setup Java for Windows'
condition: eq( variables['Agent.OS'], 'Windows_NT' )
- pwsh: |
.\setup-tests-pipeline.ps1
displayName: 'Setup test environment -- Install the Core Tools'
- pwsh: |
$currDir = Get-Location
$Env:Path = $Env:Path+";$currDir/Azure.Functions.Cli"
func --version
condition: eq( variables['Agent.OS'], 'Windows_NT' )
displayName: 'Setup Core Tools - Windows'
- bash: |
chmod +x ./Azure.Functions.Cli/func
chmod +x ./Azure.Functions.Cli/gozip
export PATH=$PATH:./Azure.Functions.Cli
func --version
condition: eq( variables['Agent.OS'], 'Linux' )
displayName: 'Setup Core Tools - Linux'
- pwsh: |
cd ./endtoendtests
mvn clean package `-Dmaven`.javadoc`.skip=true `-Dmaven`.test`.skip `-Dorg`.slf4j`.simpleLogger`.log`.org`.apache`.maven`.cli`.transfer`.Slf4jMavenTransferListener=warn `-B
Copy-Item "confluent_cloud_cacert.pem" "./target/azure-functions/azure-functions-java-endtoendtests"
displayName: 'Package Java for E2E'
- task: DotNetCoreCLI@2
inputs:
command: 'test'
projects: |
endtoendtests/Azure.Functions.Java.Tests.E2E/Azure.Functions.Java.Tests.E2E/Azure.Functions.Java.Tests.E2E.csproj
env:
JAVA_HOME: $(JavaHome)
AzureWebJobsStorage: $(AzureWebJobsStorage)
AzureWebJobsCosmosDBConnectionString: $(AzureWebJobsCosmosDBConnectionString)
AzureWebJobsServiceBus: $(AzureWebJobsServiceBus)
AzureWebJobsEventHubReceiver: $(AzureWebJobsEventHubReceiver)
AzureWebJobsEventHubSender_2: $(AzureWebJobsEventHubSender_2)
AzureWebJobsEventHubSender: $(AzureWebJobsEventHubSender)
AzureWebJobsEventHubPath: $(AzureWebJobsEventHubPath)
SBTopicName: $(SBTopicName)
SBTopicSubName: $(SBTopicSubName)
CosmosDBDatabaseName: $(CosmosDBDatabaseName)
SBQueueName: $(SBQueueName)
BrokerList": $(BrokerList)
ConfluentCloudUsername: $(ConfluentCloudUsername)
ConfluentCloudPassword: $(ConfluentCloudPassword)
AzureWebJobsEventGridOutputBindingTopicUriString: $(AzureWebJobsEventGridOutputBindingTopicUriString)
AzureWebJobsEventGridOutputBindingTopicKeyString: $(AzureWebJobsEventGridOutputBindingTopicKeyString)
displayName: 'Build & Run tests'
continueOnError: false
- job: "Publish"
displayName: 'Publish build artifacts'
dependsOn: Test
pool:
name: '1ES-Hosted-AzFunc'
demands:
- ImageOverride -equals MMS2019TLS
steps:
- task: DownloadBuildArtifacts@0
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'buildDrop'
downloadPath: '$(Build.ArtifactStagingDirectory)'
displayName: 'Download build artifacts'
- pwsh: |
Move-Item -Path "$(Build.ArtifactStagingDirectory)/buildDrop/*.nupkg" -Destination $(Build.ArtifactStagingDirectory)
Remove-Item "$(Build.ArtifactStagingDirectory)/buildDrop" -Recurse
- task: ManifestGeneratorTask@0
inputs:
BuildDropPath: '$(Build.ArtifactStagingDirectory)'
Verbosity: 'Information'
displayName: 'SBOM Generation Task'
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'
displayName: 'Publishing build artifacts'
- task: NuGetCommand@2
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/dev'), eq(variables['UPLOADPACKAGETOPRERELEASEFEED'], true))
inputs:
command: 'push'
packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg'
nuGetFeedType: 'internal'
publishVstsFeed: 'e6a70c92-4128-439f-8012-382fe78d6396/f37f760c-aebd-443e-9714-ce725cd427df'
allowPackageConflicts: true
displayName: 'Push NuGet package to the AzureFunctionsPreRelease feed'