268 lines
12 KiB
YAML
268 lines
12 KiB
YAML
# default-build.yml
|
|
# Description: Defines a build phase for invoking build.sh/cmd
|
|
# Parameters:
|
|
# jobName: string
|
|
# The name of the job. Defaults to the name of the OS. No spaces allowed
|
|
# jobDisplayName: string
|
|
# The friendly job name to display in the UI. Defaults to the name of the OS.
|
|
# agentOs: string
|
|
# Used in templates to define variables which are OS specific. Typically from the set { Windows, Linux, macOS }
|
|
# buildArgs: string
|
|
# Additional arguments to pass to the build.sh/cmd script.
|
|
# Note: -ci is always passed
|
|
# beforeBuild: [steps]
|
|
# Additional steps to run before build.sh/cmd
|
|
# steps: [steps]
|
|
# Instead of running build.cmd/sh, run these build steps.
|
|
# afterBuild: [steps]
|
|
# Additional steps to run after build.sh/cmd
|
|
# artifacts: [array]
|
|
# name: string
|
|
# The name of the artifact container
|
|
# - path: string
|
|
# The file path to artifacts output
|
|
# includeForks: boolean
|
|
# Should artifacts from forks be published?
|
|
# publishOnError: boolean
|
|
# Should artifacts be published if previous step failed?
|
|
# dependsOn: string | [ string ]
|
|
# For fan-out/fan-in. https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=schema#job
|
|
# condition: string
|
|
# A condition which can be used to skip the job completely
|
|
# codeSign: boolean
|
|
# This build definition is enabled for code signing. (Only applies to Windows)
|
|
# buildDirectory: string
|
|
# Specifies what directory to run build.sh/cmd
|
|
# buildScript: string
|
|
# Specifies the build script to run. Defaults to build.sh or build.cmd.
|
|
|
|
#
|
|
# See https://docs.microsoft.com/en-us/vsts/pipelines/yaml-schema for details
|
|
#
|
|
|
|
parameters:
|
|
agentOs: 'Windows'
|
|
buildArgs: ''
|
|
configuration: 'Release'
|
|
beforeBuild: []
|
|
# steps: [] don't define an empty object default because there is no way in template expression yet to check "if isEmpty(parameters.steps)"
|
|
afterBuild: []
|
|
codeSign: false
|
|
dependsOn: ''
|
|
condition: ''
|
|
# jobName: '' - use agentOs by default.
|
|
# jobDisplayName: '' - use agentOs by default.
|
|
artifacts: []
|
|
buildDirectory: ''
|
|
buildScript: ''
|
|
installTar: true
|
|
installNodeJs: true
|
|
installJdk: true
|
|
timeoutInMinutes: 180
|
|
useHostedUbuntu: true
|
|
|
|
# We need longer than the default amount of 5 minutes to upload our logs/artifacts. (We currently take around 5 mins in the best case).
|
|
# This makes sure we have time to upload everything in the case of a build timeout - really important for investigating a build
|
|
# timeout due to test hangs.
|
|
cancelTimeoutInMinutes: 15
|
|
|
|
jobs:
|
|
- template: /eng/common/templates/job/job.yml
|
|
parameters:
|
|
name: ${{ coalesce(parameters.jobName, parameters.agentOs) }}
|
|
displayName: ${{ coalesce(parameters.jobDisplayName, parameters.agentOs) }}
|
|
dependsOn: ${{ parameters.dependsOn }}
|
|
${{ if ne(parameters.condition, '') }}:
|
|
condition: ${{ parameters.condition }}
|
|
timeoutInMinutes: ${{ parameters.timeoutInMinutes }}
|
|
cancelTimeoutInMinutes: ${{ parameters.cancelTimeoutInMinutes }}
|
|
${{ if and(eq(variables['System.TeamProject'], 'internal'), eq(parameters.agentOs, 'Windows'), eq(parameters.codeSign, 'true')) }}:
|
|
enableMicrobuild: true
|
|
enablePublishBuildAssets: true
|
|
enablePublishUsingPipelines: ${{ variables._PublishUsingPipelines }}
|
|
enablePublishTestResults: true # publish test results to AzDO (populates AzDO Tests tab)
|
|
enableTelemetry: true
|
|
helixRepo: dotnet/aspnetcore
|
|
helixType: build.product/
|
|
workspace:
|
|
clean: all
|
|
# Map friendly OS names to the right queue
|
|
# See https://github.com/dotnet/arcade/blob/master/Documentation/ChoosingAMachinePool.md
|
|
pool:
|
|
${{ if eq(parameters.agentOs, 'macOS') }}:
|
|
vmImage: macOS-10.14
|
|
${{ if eq(parameters.agentOs, 'Linux') }}:
|
|
${{ if eq(parameters.useHostedUbuntu, true) }}:
|
|
vmImage: ubuntu-16.04
|
|
${{ if eq(parameters.useHostedUbuntu, false) }}:
|
|
${{ if eq(variables['System.TeamProject'], 'public') }}:
|
|
name: NetCorePublic-Pool
|
|
queue: BuildPool.Ubuntu.1604.Amd64.Open
|
|
${{ if eq(variables['System.TeamProject'], 'internal') }}:
|
|
name: NetCoreInternal-Pool
|
|
queue: BuildPool.Ubuntu.1604.Amd64
|
|
${{ if eq(parameters.agentOs, 'Windows') }}:
|
|
${{ if eq(variables['System.TeamProject'], 'public') }}:
|
|
name: NetCorePublic-Pool
|
|
${{ if ne(parameters.isTestingJob, true) }}:
|
|
# Visual Studio Build Tools
|
|
queue: BuildPool.Server.Amd64.VS2019.BT.Open
|
|
${{ if eq(parameters.isTestingJob, true) }}:
|
|
# Visual Studio Enterprise - contains some stuff, like SQL Server and IIS Express, that we use for testing
|
|
queue: BuildPool.Server.Amd64.VS2019.Open
|
|
${{ if eq(variables['System.TeamProject'], 'internal') }}:
|
|
name: NetCoreInternal-Pool
|
|
# Visual Studio Enterprise - contains some stuff, like SQL Server and IIS Express, that we use for testing
|
|
queue: BuildPool.Server.Amd64.VS2019
|
|
variables:
|
|
- AgentOsName: ${{ parameters.agentOs }}
|
|
- ASPNETCORE_TEST_LOG_MAXPATH: "200" # Keep test log file name length low enough for artifact zipping
|
|
- BuildScript: ${{ parameters.buildScript }}
|
|
- BuildScriptArgs: ${{ parameters.buildArgs }}
|
|
- _BuildConfig: ${{ parameters.configuration }}
|
|
- BuildConfiguration: ${{ parameters.configuration }}
|
|
- BuildDirectory: ${{ parameters.buildDirectory }}
|
|
- DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
|
|
- TeamName: AspNetCore
|
|
- ${{ if and(eq(parameters.installJdk, 'true'), eq(parameters.agentOs, 'Windows')) }}:
|
|
- JAVA_HOME: $(Agent.BuildDirectory)\.tools\jdk\win-x64
|
|
- ${{ if or(ne(parameters.codeSign, true), ne(variables['System.TeamProject'], 'internal')) }}:
|
|
- _SignType: ''
|
|
- ${{ if and(eq(parameters.codeSign, true), eq(variables['System.TeamProject'], 'internal')) }}:
|
|
- ${{ if notin(variables['Build.Reason'], 'PullRequest') }}:
|
|
- _SignType: real
|
|
- ${{ if in(variables['Build.Reason'], 'PullRequest') }}:
|
|
- _SignType: test
|
|
steps:
|
|
- checkout: self
|
|
clean: true
|
|
- ${{ if and(eq(parameters.agentOs, 'Windows'), eq(parameters.isTestingJob, true)) }}:
|
|
- powershell: ./eng/scripts/InstallProcDump.ps1
|
|
displayName: Install ProcDump
|
|
- powershell: ./eng/scripts/StartDumpCollectionForHangingBuilds.ps1 $(ProcDumpPath)procdump.exe artifacts/dumps/ (Get-Date).AddMinutes(160) dotnet
|
|
displayName: Start background dump collection
|
|
- ${{ if eq(parameters.installNodeJs, 'true') }}:
|
|
- task: NodeTool@0
|
|
displayName: Install Node 10.x
|
|
inputs:
|
|
versionSpec: 10.x
|
|
- ${{ if eq(parameters.agentOs, 'Windows') }}:
|
|
- task: NuGetToolInstaller@1
|
|
- task: NuGetCommand@2
|
|
displayName: 'Clear NuGet caches'
|
|
condition: succeeded()
|
|
inputs:
|
|
command: custom
|
|
arguments: 'locals all -clear'
|
|
- ${{ if and(eq(parameters.installJdk, 'true'), eq(parameters.agentOs, 'Windows')) }}:
|
|
- powershell: ./eng/scripts/InstallJdk.ps1
|
|
displayName: Install JDK 11
|
|
- ${{ if eq(parameters.isTestingJob, true) }}:
|
|
- powershell: |
|
|
Write-Host "##vso[task.setvariable variable=SeleniumProcessTrackingFolder]$(BuildDirectory)\artifacts\tmp\selenium\"
|
|
./eng/scripts/InstallGoogleChrome.ps1
|
|
displayName: Install Chrome
|
|
- ${{ if and(eq(parameters.installTar, 'true'), eq(parameters.agentOs, 'Windows')) }}:
|
|
- powershell: ./eng/scripts/InstallTar.ps1
|
|
displayName: Find or install Tar
|
|
|
|
- ${{ parameters.beforeBuild }}
|
|
|
|
- ${{ if ne(parameters.steps, '')}}:
|
|
- ${{ parameters.steps }}
|
|
- ${{ if eq(parameters.steps, '')}}:
|
|
- ${{ if ne(variables['System.TeamProject'], 'public') }}:
|
|
- ${{ if eq(parameters.agentOs, 'Windows') }}:
|
|
- ${{ if ne(variables['System.TeamProject'], 'public') }}:
|
|
- task: PowerShell@2
|
|
displayName: Setup Private Feeds Credentials
|
|
inputs:
|
|
filePath: $(Build.SourcesDirectory)/eng/common/SetupNugetSources.ps1
|
|
arguments: -ConfigFile $(Build.SourcesDirectory)/NuGet.config -Password $Env:Token
|
|
env:
|
|
Token: $(dn-bot-dnceng-artifact-feeds-rw)
|
|
- ${{ if ne(parameters.agentOs, 'Windows') }}:
|
|
- task: Bash@3
|
|
displayName: Setup Private Feeds Credentials
|
|
inputs:
|
|
filePath: $(Build.SourcesDirectory)/eng/common/SetupNugetSources.sh
|
|
arguments: $(Build.SourcesDirectory)/NuGet.config $Token
|
|
env:
|
|
Token: $(dn-bot-dnceng-artifact-feeds-rw)
|
|
- ${{ if eq(parameters.buildScript, '') }}:
|
|
- ${{ if eq(parameters.agentOs, 'Windows') }}:
|
|
- script: .\$(BuildDirectory)\build.cmd -ci /p:DotNetSignType=$(_SignType) -Configuration $(BuildConfiguration) $(BuildScriptArgs)
|
|
displayName: Run build.cmd
|
|
- ${{ if ne(parameters.agentOs, 'Windows') }}:
|
|
- script: ./$(BuildDirectory)/build.sh -ci -configuration $(BuildConfiguration) $(BuildScriptArgs)
|
|
displayName: Run build.sh
|
|
- ${{ if ne(parameters.buildScript, '') }}:
|
|
- script: $(BuildScript) -Configuration $(BuildConfiguration) $(BuildScriptArgs)
|
|
displayName: run $(BuildScript)
|
|
|
|
- ${{ parameters.afterBuild }}
|
|
|
|
- ${{ if and(eq(parameters.agentOs, 'Windows'), eq(parameters.isTestingJob, true)) }}:
|
|
- powershell: ./eng/scripts/FinishDumpCollectionForHangingBuilds.ps1 artifacts/dumps/
|
|
displayName: Finish background dump collection
|
|
continueOnError: true
|
|
condition: always()
|
|
|
|
- ${{ if eq(parameters.agentOs, 'Windows') }}:
|
|
- powershell: eng\scripts\KillProcesses.ps1
|
|
displayName: Kill processes
|
|
continueOnError: true
|
|
condition: always()
|
|
- ${{ if ne(parameters.agentOs, 'Windows') }}:
|
|
- script: eng/scripts/KillProcesses.sh
|
|
displayName: Kill processes
|
|
continueOnError: true
|
|
condition: always()
|
|
|
|
- ${{ each artifact in parameters.artifacts }}:
|
|
- task: PublishBuildArtifacts@1
|
|
displayName: Upload artifacts from ${{ artifact.path }}
|
|
condition: and(or(succeeded(), eq('${{ artifact.publishOnError }}', 'true')), or(eq(variables['system.pullrequest.isfork'], false), eq('${{ artifact.includeForks }}', 'true')))
|
|
continueOnError: true
|
|
inputs:
|
|
${{ if eq(parameters.buildDirectory, '') }}:
|
|
pathtoPublish: ${{ artifact.path }}
|
|
${{ if ne(parameters.buildDirectory, '') }}:
|
|
pathtoPublish: ${{ parameters.buildDirectory }}\${{ artifact.path }}
|
|
${{ if eq(artifact.name, '') }}:
|
|
artifactName: artifacts-$(AgentOsName)-$(BuildConfiguration)
|
|
${{ if ne(artifact.name, '') }}:
|
|
artifactName: ${{ artifact.name }}
|
|
artifactType: Container
|
|
parallel: true
|
|
|
|
- ${{ if eq(parameters.isTestingJob, true) }}:
|
|
- task: PublishTestResults@2
|
|
displayName: Publish VSTest test results
|
|
condition: always()
|
|
continueOnError: true
|
|
inputs:
|
|
testRunTitle: $(AgentOsName)-$(BuildConfiguration)
|
|
testRunner: vstest
|
|
testResultsFiles: '**/artifacts/**/*.trx'
|
|
mergeTestResults: true
|
|
buildConfiguration: $(BuildConfiguration)
|
|
buildPlatform: $(AgentOsName)
|
|
- task: PublishTestResults@2
|
|
displayName: Publish js test results
|
|
condition: always()
|
|
inputs:
|
|
testRunner: junit
|
|
testResultsFiles: '**/artifacts/log/**/*.junit.xml'
|
|
buildConfiguration: $(BuildConfiguration)
|
|
buildPlatform: $(AgentOsName)
|
|
- task: PublishTestResults@2
|
|
displayName: Publish Java test results
|
|
condition: always()
|
|
inputs:
|
|
testRunner: junit
|
|
testResultsFiles: '**/TEST-junit-jupiter.xml'
|
|
buildConfiguration: $(BuildConfiguration)
|
|
buildPlatform: $(AgentOsName)
|
|
mergeTestResults: true
|