142 lines
4.4 KiB
YAML
142 lines
4.4 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:
|
|
# https://aka.ms/yaml
|
|
|
|
name: $(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)$(postfix)$(branchName) # NOTE: rev resets when the default retention period expires
|
|
|
|
trigger:
|
|
branches:
|
|
include:
|
|
- '*'
|
|
|
|
pool:
|
|
vmImage: ubuntu-latest # ubuntu-latest - set to windows-latest or another Windows vmImage for Windows builds
|
|
|
|
variables:
|
|
solution: '**/*.sln'
|
|
buildPlatform: 'Any CPU'
|
|
buildConfiguration: 'Release'
|
|
containerRegistry: esuite.azurecr.io
|
|
DOCKER_BUILDKIT: 1
|
|
|
|
apiImageName: 'e-suite.api'
|
|
migratorImageName: 'e-suite.database.migrator'
|
|
|
|
apiPublishPath: $(Build.Repository.LocalPath)/build/eSuite.API
|
|
migratorPublishPath: $(Build.ArtifactStagingDirectory)/build/e-suite.Database.Migrator
|
|
|
|
${{ if eq(variables['Build.SourceBranchName'], 'master') }}:
|
|
branchName: ''
|
|
${{ elseif startsWith(variables['Build.SourceBranch'], 'refs/heads/') }}:
|
|
branchName: $[ replace(replace(variables['Build.SourceBranch'], 'refs/heads/', ''), '/', '-' ) ]
|
|
${{ elseif startsWith(variables['Build.SourceBranch'], 'refs/pull/') }}:
|
|
branchName: $[ replace(replace(variables['System.PullRequest.TargetBranch'], 'refs/heads/', ''), '/', '-' ) ]
|
|
|
|
${{ if eq(variables['branchName'], '') }}:
|
|
postfix: ''
|
|
${{ else }}:
|
|
postfix: '-'
|
|
|
|
steps:
|
|
- task: UseDotNet@2
|
|
displayName: 'Set .net core version'
|
|
inputs:
|
|
version: '9.0.x'
|
|
|
|
- task: DotNetCoreCLI@2
|
|
displayName: 'Nuget Restore'
|
|
inputs:
|
|
command: 'restore'
|
|
feedsToUse: config
|
|
projects: '**/*.csproj'
|
|
nugetConfigPath: nuget.config
|
|
|
|
- task: DotNetCoreCLI@2
|
|
inputs:
|
|
command: 'build'
|
|
arguments: '--configuration $(buildConfiguration)'
|
|
displayName: 'dotnet build $(buildConfiguration)'
|
|
|
|
- task: DotNetCoreCLI@2
|
|
displayName: 'Run Tests'
|
|
inputs:
|
|
command: test
|
|
projects: '**/*Tests/*.csproj'
|
|
arguments: '--configuration $(buildConfiguration) --collect "Code coverage" --settings .runsettings'
|
|
|
|
- task: DotNetCoreCLI@2
|
|
displayName: 'Publish e-suite.API'
|
|
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
|
|
inputs:
|
|
command: publish
|
|
projects: 'eSuite.API/eSuite.API.csproj'
|
|
publishWebProjects: false
|
|
arguments: -c $(BuildConfiguration) -o build
|
|
zipAfterPublish: false
|
|
|
|
- task: Docker@2
|
|
displayName: Build e-suite API Image
|
|
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
|
|
inputs:
|
|
command: build
|
|
repository: $(apiImageName)
|
|
buildContext: $(apiPublishPath)
|
|
Dockerfile: $(apiPublishPath)/Dockerfile.Azure
|
|
containerRegistry: |
|
|
$(containerRegistry)
|
|
tags: |
|
|
$(Build.BuildNumber)
|
|
|
|
- task: DotNetCoreCLI@2
|
|
displayName: 'Publish e-suite.Database.Migrator'
|
|
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
|
|
inputs:
|
|
command: publish
|
|
projects: 'e-suite.Database.Migrator/e-suite.Database.Migrator.csproj'
|
|
publishWebProjects: false
|
|
arguments: '--configuration $(BuildConfiguration) --output $(migratorPublishPath)'
|
|
zipAfterPublish: false
|
|
|
|
- powershell: |
|
|
Write-Host "Show all folder content"
|
|
Get-ChildItem -Path $(migratorPublishPath)\*.* -Recurse -Force | % { $_.FullName }
|
|
errorActionPreference: continue
|
|
displayName: 'PowerShell Script List folder structure'
|
|
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
|
|
continueOnError: true
|
|
|
|
- task: Docker@2
|
|
displayName: Build e-suite Database Migrator image
|
|
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
|
|
inputs:
|
|
command: build
|
|
repository: $(migratorImageName)
|
|
buildContext: $(migratorPublishPath)/e-suite.Database.Migrator
|
|
Dockerfile: $(migratorPublishPath)/e-suite.Database.Migrator/Dockerfile.Azure
|
|
containerRegistry: |
|
|
$(containerRegistry)
|
|
tags: |
|
|
$(Build.BuildNumber)
|
|
|
|
- task: Docker@2
|
|
displayName: Push e-suite API Image
|
|
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
|
|
inputs:
|
|
command: push
|
|
repository: $(apiImageName)
|
|
containerRegistry: |
|
|
$(containerRegistry)
|
|
tags: |
|
|
$(Build.BuildNumber)
|
|
|
|
- task: Docker@2
|
|
displayName: Push e-suite Database Migrator image
|
|
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
|
|
inputs:
|
|
command: push
|
|
repository: $(migratorImageName)
|
|
containerRegistry: |
|
|
$(containerRegistry)
|
|
tags: |
|
|
$(Build.BuildNumber) |