# 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. # skipComponentGovernanceDetection: boolean # Determines if component governance detection can be skipped # # 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 skipComponentGovernanceDetection: false # 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: ${{ eq(parameters.isTestingJob, '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-18.04 ${{ if eq(parameters.useHostedUbuntu, false) }}: ${{ if eq(variables['System.TeamProject'], 'public') }}: name: NetCorePublic-Pool queue: BuildPool.Ubuntu.1804.Amd64.Open ${{ if eq(variables['System.TeamProject'], 'internal') }}: name: NetCoreInternal-Pool queue: BuildPool.Ubuntu.1804.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 ${{ if ne(parameters.container, '') }}: container: ${{ parameters.container }} 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 }} - ${{ if eq(parameters.buildDirectory, '') }}: - BuildDirectory: $(System.DefaultWorkingDirectory) - ${{ if ne(parameters.buildDirectory, '') }}: - BuildDirectory: ${{ parameters.buildDirectory }} - DOTNET_CLI_HOME: $(System.DefaultWorkingDirectory) - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - TeamName: AspNetCore - ${{ 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 - LC_ALL: 'en_US.UTF-8' - LANG: 'en_US.UTF-8' - LANGUAGE: 'en_US.UTF-8' steps: - ${{ if ne(parameters.agentOs, 'Windows') }}: - script: df -h displayName: Disk size - 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]$(Build.SourcesDirectory)\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 - ${{ if eq(parameters.agentOs, 'Windows') }}: - powershell: Write-Host "##vso[task.prependpath]$(DOTNET_CLI_HOME)\.dotnet\tools" displayName: Add dotnet tools to path - ${{ if ne(parameters.agentOs, 'Windows') }}: - script: echo "##vso[task.prependpath]$(DOTNET_CLI_HOME)/.dotnet/tools" displayName: Add dotnet tools to path - ${{ parameters.beforeBuild }} - ${{ 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 ne(parameters.steps, '')}}: - ${{ parameters.steps }} - ${{ if eq(parameters.steps, '')}}: - ${{ if eq(parameters.buildScript, '') }}: - ${{ if eq(parameters.agentOs, 'Windows') }}: - script: $(BuildDirectory)\build.cmd -ci -nobl -Configuration $(BuildConfiguration) $(BuildScriptArgs) /p:DotNetSignType=$(_SignType) displayName: Run build.cmd - ${{ if ne(parameters.agentOs, 'Windows') }}: - script: $(BuildDirectory)/build.sh --ci --nobl --configuration $(BuildConfiguration) $(BuildScriptArgs) displayName: Run build.sh - ${{ if ne(parameters.buildScript, '') }}: - script: $(BuildScript) -ci -nobl -Configuration $(BuildConfiguration) $(BuildScriptArgs) displayName: run $(BuildScript) - ${{ parameters.afterBuild }} - ${{ if eq(parameters.agentOs, 'Linux') }}: - script: df -h && du -h --threshold=50MB .. displayName: Disk utilization - ${{ if eq(parameters.agentOs, 'macOS') }}: - script: df -h && du -h -d 3 .. displayName: Disk utilization - ${{ 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() # Run component detection after all successful Build:* jobs unless overridden e.g. for Alpine build. - ${{ if and(startsWith(parameters.jobDisplayName, 'Build:'), ne(variables['skipComponentGovernanceDetection'], 'true'), ne(parameters.skipComponentGovernanceDetection, 'true'), notin(variables['Build.Reason'], 'PullRequest')) }}: - task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0 condition: and(succeeded(), ne(variables['CG_RAN'], 'true')) displayName: 'Component Detection' inputs: ${{ if eq(parameters.agentOs, 'Windows') }}: ignoreDirectories: '.dotnet,.packages,artifacts\log,artifacts\symbols,artifacts\tmp' ${{ if ne(parameters.agentOs, 'Windows') }}: ignoreDirectories: '.dotnet,.packages,artifacts/log,artifacts/symbols,artifacts/tmp' sourceScanPath: $(Build.SourcesDirectory) verbosity: Verbose # Make sure auto-injected component detection does _not_ execute in other jobs nor when overridden. # No need to recheck variables or build reason because auto-injected component detection honors those values. - ${{ if or(not(startsWith(parameters.jobDisplayName, 'Build:')), eq(parameters.skipComponentGovernanceDetection, 'true')) }}: - script: echo "##vso[task.setvariable variable=CG_RAN]true" displayName: 'Skip Component Detection' - ${{ 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: pathtoPublish: $(Build.SourcesDirectory)/${{ artifact.path }} ${{ if eq(artifact.name, '') }}: artifactName: artifacts-$(AgentOsName)-$(BuildConfiguration) ${{ if ne(artifact.name, '') }}: artifactName: ${{ artifact.name }} artifactType: Container parallel: true - ${{ if and(eq(parameters.isTestingJob, true), ne(parameters.jobName, 'Windows_Templates_Test')) }}: - task: PublishTestResults@2 displayName: Publish js test results condition: always() inputs: testRunner: junit testResultsFiles: '**/artifacts/log/**/*.junit.xml' buildConfiguration: $(BuildConfiguration) buildPlatform: $(AgentOsName)