Created
October 29, 2021 17:16
-
-
Save pwelter34/6fd18ffbd5c326d423d0c237844ab8f1 to your computer and use it in GitHub Desktop.
Standard web project with database
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trigger: | |
- main | |
- develop | |
- releases/* | |
variables: | |
major: 1 | |
minor: 0 | |
name: $(major).$(minor).$(Rev:r) | |
stages: | |
- stage: BuildProject | |
displayName: 'Build Project Source' | |
jobs: | |
- job: BuildWebApplication | |
displayName: 'Build Web Application' | |
variables: | |
solution: '**/*.sln' | |
buildPlatform: 'Any CPU' | |
buildConfiguration: 'Release' | |
pool: | |
vmImage: 'windows-latest' | |
steps: | |
- powershell: | | |
Write-Host "Build.BuildNumber: $(Build.BuildNumber)" | |
Write-Host "Build.Reason: $(Build.Reason)" | |
Write-Host "Build.SourceBranch: $(Build.SourceBranch)" | |
Write-Host "Build.SourceBranchName: $(Build.SourceBranchName)" | |
Write-Host "Build.SourceVersion: $(Build.SourceVersion)" | |
- task: UseDotNet@2 | |
displayName: 'Install .NET SDK' | |
inputs: | |
packageType: sdk | |
version: 5.0.x | |
performMultiLevelLookup: true | |
- task: NodeTool@0 | |
displayName: 'Install Node' | |
inputs: | |
versionSpec: '16.x' | |
- script: npm version $(Build.BuildNumber) | |
displayName: 'Update Client Version' | |
workingDirectory: 'client' | |
- task: Npm@1 | |
displayName: 'Install Client Dependencies' | |
inputs: | |
command: 'install' | |
workingDir: 'client' | |
verbose: true | |
- task: Npm@1 | |
displayName: 'Build Client' | |
inputs: | |
command: 'custom' | |
workingDir: 'client' | |
customCommand: 'run build' | |
verbose: true | |
- task: CopyFiles@2 | |
displayName: 'Copy Client Files' | |
inputs: | |
SourceFolder: 'client/dist' | |
Contents: '**/*' | |
TargetFolder: 'server/Apex.Security.Web/wwwroot' | |
OverWrite: true | |
- task: DotNetCoreCLI@2 | |
displayName: 'Restore Dependencies' | |
inputs: | |
command: 'restore' | |
projects: 'server/Apex.Security.sln' | |
feedsToUse: 'select' | |
vstsFeed: 'cfb26406-cd12-4247-aa3b-514b8ee488da' | |
- task: DotNetCoreCLI@2 | |
displayName: 'Run Unit Tests' | |
inputs: | |
command: 'test' | |
projects: 'server/Tests/**/*.csproj' | |
arguments: '--no-restore --configuration $(BuildConfiguration) --collect:"XPlat Code Coverage" --settings ./server/coverlet.runsettings' | |
- script: 'dotnet tool install --global dotnet-reportgenerator-globaltool' | |
displayName: 'Install ReportGenerator tool' | |
- script: 'reportgenerator -reports:$(Agent.TempDirectory)/**/coverage.cobertura.xml -targetdir:$(Agent.TempDirectory)/CodeCoverage -reporttypes:"Cobertura"' | |
displayName: 'Create Code Coverage Reports' | |
- task: PublishCodeCoverageResults@1 | |
displayName: 'Publish Code Coverage' | |
inputs: | |
codeCoverageTool: Cobertura | |
summaryFileLocation: '$(Agent.TempDirectory)/CodeCoverage/Cobertura.xml' | |
- task: DotNetCoreCLI@2 | |
displayName: 'Build Server' | |
inputs: | |
command: 'publish' | |
publishWebProjects: false | |
projects: 'server/Apex.Security.Web/Apex.Security.Web.csproj' | |
arguments: '--no-restore --configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory) -p:Version=$(Build.BuildNumber) -p:InformationalVersion="$(Build.BuildNumber)+Branch.$(Build.SourceBranchName).Sha.$(Build.SourceVersion)"' | |
- task: MSBuild@1 | |
displayName: 'Build Database' | |
inputs: | |
solution: 'database/Apex/Apex.sqlproj' | |
configuration: $(BuildConfiguration) | |
msbuildArguments: '/p:OutDir=$(Build.ArtifactStagingDirectory)' | |
- task: PublishBuildArtifacts@1 | |
displayName: 'Publish Artifact' | |
inputs: | |
PathtoPublish: '$(Build.ArtifactStagingDirectory)' | |
ArtifactName: 'Artifacts' | |
- stage: DeployDevelop | |
displayName: 'Deploy to Development Environment' | |
condition: and(succeeded(), eq(variables['build.sourceBranch'], 'refs/heads/develop')) | |
variables: | |
- group: 'Develop' | |
jobs: | |
- deployment: | |
pool: | |
vmImage: 'windows-latest' | |
environment: 'Develop' | |
strategy: | |
runOnce: | |
deploy: | |
steps: | |
- task: SqlAzureDacpacDeployment@1 | |
displayName: 'Deploy SQL Database Package' | |
inputs: | |
azureSubscription: 'ARC Subscription Service Connection' | |
AuthenticationType: 'server' | |
ServerName: '$(SqlServer)' | |
DatabaseName: '$(SqlDatabase)' | |
SqlUsername: '$(SqlUsername)' | |
SqlPassword: '$(SqlPassword)' | |
DacpacFile: '$(Pipeline.Workspace)/Artifacts/Apex.dacpac' | |
AdditionalArguments: '/p:BlockOnPossibleDataLoss=false' | |
- task: AzureRmWebAppDeployment@4 | |
displayName: 'Deploy Azure Web App Service' | |
inputs: | |
ConnectionType: 'AzureRM' | |
azureSubscription: 'ARC Subscription Service Connection' | |
appType: 'webApp' | |
WebAppName: '$(SecurityAppName)' | |
packageForLinux: '$(Pipeline.Workspace)/Artifacts/Apex.Security.Web.zip' | |
enableCustomDeployment: true | |
DeploymentType: 'zipDeploy' | |
- stage: DeployTest | |
displayName: 'Deploy to Test Environment' | |
condition: and(succeeded(), eq(variables['build.sourceBranch'], 'refs/heads/main')) | |
variables: | |
- group: 'Test' | |
jobs: | |
- deployment: | |
pool: | |
vmImage: 'windows-latest' | |
environment: 'Test' | |
strategy: | |
runOnce: | |
deploy: | |
steps: | |
- task: SqlAzureDacpacDeployment@1 | |
displayName: 'Deploy SQL Database Package' | |
inputs: | |
azureSubscription: 'ARC Subscription Service Connection' | |
AuthenticationType: 'server' | |
ServerName: '$(SqlServer)' | |
DatabaseName: '$(SqlDatabase)' | |
SqlUsername: '$(SqlUsername)' | |
SqlPassword: '$(SqlPassword)' | |
DacpacFile: '$(Pipeline.Workspace)/Artifacts/Apex.dacpac' | |
AdditionalArguments: '/p:BlockOnPossibleDataLoss=false' | |
- task: AzureRmWebAppDeployment@4 | |
displayName: 'Deploy Azure Web App Service' | |
inputs: | |
ConnectionType: 'AzureRM' | |
azureSubscription: 'ARC Subscription Service Connection' | |
appType: 'webApp' | |
WebAppName: '$(SecurityAppName)' | |
packageForLinux: '$(Pipeline.Workspace)/Artifacts/Apex.Security.Web.zip' | |
enableCustomDeployment: true | |
DeploymentType: 'zipDeploy' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment