|
| 1 | +# default-build.yml |
| 2 | +# Description: Defines a build phase for invoking build.sh/cmd |
| 3 | +# Parameters: |
| 4 | +# jobName: string |
| 5 | +# The name of the job. Defaults to the name of the OS. No spaces allowed |
| 6 | +# jobDisplayName: string |
| 7 | +# The friendly job name to display in the UI. Defaults to the name of the OS. |
| 8 | +# poolName: string |
| 9 | +# The name of the Azure DevOps agent pool to use. |
| 10 | +# agentOs: string |
| 11 | +# Used in templates to define variables which are OS specific. Typically from the set { Windows, Linux, macOS } |
| 12 | +# buildArgs: string |
| 13 | +# Additional arguments to pass to the build.sh/cmd script. |
| 14 | +# Note: -ci is always passed |
| 15 | +# beforeBuild: [steps] |
| 16 | +# Additional steps to run before build.sh/cmd |
| 17 | +# afterBuild: [steps] |
| 18 | +# Additional steps to run after build.sh/cmd |
| 19 | +# artifacts: |
| 20 | +# publish: boolean |
| 21 | +# Should artifacts be published |
| 22 | +# path: string |
| 23 | +# The file path to artifacts output |
| 24 | +# name: string |
| 25 | +# The name of the artifact container |
| 26 | +# variables: { string: string } |
| 27 | +# A map of custom variables |
| 28 | +# matrix: { string: { string: string } } |
| 29 | +# A map of matrix configurations and variables. https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=schema#job |
| 30 | +# demands: string | [ string ] |
| 31 | +# A list of agent demands. https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=schema#demands |
| 32 | +# dependsOn: string | [ string ] |
| 33 | +# For fan-out/fan-in. https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=schema#job |
| 34 | +# codeSign: boolean |
| 35 | +# This build definition is enabled for code signing. (Only applies to Windows) |
| 36 | + |
| 37 | +# |
| 38 | +# See https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema for details |
| 39 | +# |
| 40 | + |
| 41 | +parameters: |
| 42 | + agentOs: 'Windows' |
| 43 | + poolName: '' |
| 44 | + buildArgs: '' |
| 45 | + configuration: 'Release' |
| 46 | + demands: [] |
| 47 | + beforeBuild: [] |
| 48 | + afterBuild: [] |
| 49 | + codeSign: false |
| 50 | + variables: {} |
| 51 | + dependsOn: '' |
| 52 | + # buildSteps: [] - don't define an empty object default because there is no way in template expression yet to check "if isEmpty(parameters.buildSteps)" |
| 53 | + # jobName: '' - use agentOs by default. |
| 54 | + # jobDisplayName: '' - use agentOs by default. |
| 55 | + # matrix: {} - don't define an empty object default because there is no way in template expression yet to check "if isEmpty(parameters.matrix)" |
| 56 | + artifacts: |
| 57 | + publish: true |
| 58 | + path: 'artifacts/' |
| 59 | + |
| 60 | +jobs: |
| 61 | +- job: ${{ coalesce(parameters.jobName, parameters.agentOs) }} |
| 62 | + displayName: ${{ coalesce(parameters.jobDisplayName, parameters.agentOs) }} |
| 63 | + dependsOn: ${{ parameters.dependsOn }} |
| 64 | + workspace: |
| 65 | + clean: all |
| 66 | + strategy: |
| 67 | + ${{ if ne(parameters.matrix, '') }}: |
| 68 | + maxParallel: 8 |
| 69 | + matrix: ${{ parameters.matrix }} |
| 70 | + # Map friendly OS names to the right queue |
| 71 | + # See https://github.com/dotnet/arcade/blob/master/Documentation/ChoosingAMachinePool.md and |
| 72 | + # https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/hosted?view=azure-devops&tabs=yaml#use-a-microsoft-hosted-agent |
| 73 | + pool: |
| 74 | + ${{ if ne(parameters.poolName, '') }}: |
| 75 | + name: ${{ parameters.poolName }} |
| 76 | + ${{ if and(eq(parameters.poolName, ''), eq(parameters.agentOs, 'macOS')) }}: |
| 77 | + vmImage: macOS-10.13 |
| 78 | + ${{ if and(eq(parameters.poolName, ''), eq(parameters.agentOs, 'Linux')) }}: |
| 79 | + vmImage: ubuntu-16.04 |
| 80 | + ${{ if and(eq(parameters.poolName, ''), eq(parameters.agentOs, 'Windows')) }}: |
| 81 | + vmImage: vs2017-win2016 |
| 82 | + ${{ if ne(variables['System.TeamProject'], 'public') }}: |
| 83 | + # This override makes the specified vmImage irrelevant. |
| 84 | + name: NetCoreInternal-Pool |
| 85 | + queue: BuildPool.Server.Amd64.VS2019 |
| 86 | + variables: |
| 87 | + AgentOsName: ${{ parameters.agentOs }} |
| 88 | + ASPNETCORE_TEST_LOG_MAXPATH: "200" # Keep test log file name length low enough for artifact zipping |
| 89 | + DOTNET_HOME: $(Agent.BuildDirectory)/.dotnet |
| 90 | + BuildScriptArgs: ${{ parameters.buildArgs }} |
| 91 | + BuildConfiguration: ${{ parameters.configuration }} |
| 92 | + DOTNET_CLI_TELEMETRY_OPTOUT: 1 # Skip signing telemetry to work around an error |
| 93 | + TeamName: AspNetCore |
| 94 | + ${{ if and(eq(parameters.codeSign, 'true'), eq(variables['System.TeamProject'], 'internal'), ne(variables['Build.Reason'], 'PullRequest')) }}: |
| 95 | + _SignType: real |
| 96 | + ${{ if or(ne(parameters.codeSign, 'true'), ne(variables['System.TeamProject'], 'internal'), eq(variables['Build.Reason'], 'PullRequest')) }}: |
| 97 | + _SignType: '' |
| 98 | + ${{ insert }}: ${{ parameters.variables }} |
| 99 | + steps: |
| 100 | + - checkout: self |
| 101 | + clean: true |
| 102 | + - ${{ if eq(parameters.agentOs, 'Windows') }}: |
| 103 | + - task: NuGetCommand@2 |
| 104 | + displayName: 'Clear NuGet caches' |
| 105 | + condition: succeeded() |
| 106 | + inputs: |
| 107 | + command: custom |
| 108 | + arguments: 'locals all -clear' |
| 109 | + - ${{ if and(eq(variables['System.TeamProject'], 'internal'), eq(parameters.agentOs, 'Windows'), eq(parameters.codeSign, 'true')) }}: |
| 110 | + - task: MicroBuildSigningPlugin@2 |
| 111 | + displayName: Install MicroBuild Signing plugin |
| 112 | + condition: and(succeeded(), in(variables['_SignType'], 'test', 'real')) |
| 113 | + inputs: |
| 114 | + signType: $(_SignType) |
| 115 | + zipSources: false |
| 116 | + feedSource: https://dnceng.pkgs.visualstudio.com/_packaging/MicroBuildToolset/nuget/v3/index.json |
| 117 | + - ${{ parameters.beforeBuild }} |
| 118 | + - ${{ if eq(parameters.buildSteps, '') }}: |
| 119 | + - ${{ if eq(parameters.agentOs, 'Windows') }}: |
| 120 | + - task: NuGetToolInstaller@1 |
| 121 | + displayName: 'Install NuGet.exe' |
| 122 | + - task: NodeTool@0 |
| 123 | + displayName: Install Node 10.x |
| 124 | + inputs: |
| 125 | + versionSpec: 10.x |
| 126 | + - script: .\build.cmd /p:SignType=$(_SignType) /p:Configuration=$(BuildConfiguration) $(BuildScriptArgs) /bl:artifacts/logs/build.binlog |
| 127 | + displayName: Run build.cmd |
| 128 | + - ${{ if ne(parameters.agentOs, 'Windows') }}: |
| 129 | + - script: ./build.sh -ci -p:Configuration=$(BuildConfiguration) $(BuildScriptArgs) |
| 130 | + displayName: Run build.sh |
| 131 | + - ${{ if ne(parameters.buildSteps, '') }}: |
| 132 | + - ${{ parameters.buildSteps }} |
| 133 | + - task: PublishTestResults@2 |
| 134 | + displayName: Publish test results |
| 135 | + condition: always() |
| 136 | + continueOnError: true |
| 137 | + inputs: |
| 138 | + testRunTitle: $(AgentOsName)-$(BuildConfiguration) |
| 139 | + testRunner: vstest |
| 140 | + testResultsFiles: 'artifacts/logs/**/*.trx' |
| 141 | + mergeTestResults: true |
| 142 | + - ${{ if eq(parameters.artifacts.publish, 'true') }}: |
| 143 | + - task: PublishBuildArtifacts@1 |
| 144 | + displayName: Upload artifacts |
| 145 | + condition: eq(variables['system.pullrequest.isfork'], false) |
| 146 | + continueOnError: true |
| 147 | + inputs: |
| 148 | + pathtoPublish: ${{ parameters.artifacts.path }} |
| 149 | + ${{ if eq(parameters.artifacts.name, '') }}: |
| 150 | + artifactName: artifacts-$(AgentOsName)-$(BuildConfiguration) |
| 151 | + ${{ if ne(parameters.artifacts.name, '') }}: |
| 152 | + artifactName: ${{ parameters.artifacts.name }} |
| 153 | + artifactType: Container |
| 154 | + parallel: true |
| 155 | + - ${{ parameters.afterBuild }} |
| 156 | + - ${{ if and(eq(variables['System.TeamProject'], 'internal'), eq(parameters.agentOs, 'Windows'), eq(parameters.codeSign, 'true')) }}: |
| 157 | + - task: MicroBuildCleanup@1 |
| 158 | + displayName: Cleanup MicroBuild tasks |
| 159 | + condition: always() |
0 commit comments