aboutsummaryrefslogtreecommitdiff
path: root/azure-pipelines.yml
blob: af2d47300011bb3d2c705efd079c05a1f52c5720 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
trigger:
  - master
  
stages:
- stage: build
  displayName: Routine Build and Test

  jobs:
  - job: build
    displayName: Build Debug and Test
    pool:
      vmImage: 'ubuntu-18.04'
    variables:
      buildConfiguration: 'Debug'
      ASPNETCORE_ENVIRONMENT: 'Development'
    steps:
    - task: UseDotNet@2
      inputs:
        packageType: sdk
        version: 3.1.x

    - script: |
        dotnet restore Timeline/Timeline.csproj --configfile nuget.config
        dotnet restore Timeline.Tests/Timeline.Tests.csproj --configfile nuget.config
      displayName: Dotnet Restore
    - script: dotnet test Timeline.Tests/Timeline.Tests.csproj --configuration $(buildConfiguration) --no-restore --logger trx --collect:"XPlat Code Coverage" --settings './Timeline.Tests/coverletArgs.runsettings'
      displayName: Dotnet Test

    - task: PublishTestResults@2
      condition: succeededOrFailed()
      inputs:
        testRunner: VSTest
        testResultsFiles: '**/*.trx'

    - task: PublishCodeCoverageResults@1
      condition: succeededOrFailed()
      inputs:
        codeCoverageTool: 'Cobertura'
        summaryFileLocation: '**/TestResults/*/coverage.cobertura.xml'

- stage: deploy
  displayName: Build Release and Deploy
  dependsOn: build
  condition: eq(variables['Build.SourceBranchName'], 'master')
  variables:
    buildConfiguration: 'Release'

  jobs:
  - job: build
    displayName: Build Release Artifact
    pool:
      vmImage: 'ubuntu-18.04'
    steps:
    - task: UseDotNet@2
      inputs:
        packageType: sdk
        version: 3.1.x

    - script: dotnet publish Timeline/Timeline.csproj --configuration $(buildConfiguration) --output ./Timeline/publish/ -r linux-x64 --self-contained false
      displayName: Dotnet Publish

    - publish: Timeline/publish
      artifact: timeline

  - deployment: deploy
    displayName: Deploy to Server
    environment: 
      name: timeline-server
      resourceType: VirtualMachine
      tags: linux
    dependsOn: build
    strategy:
      runOnce:
        deploy:
          steps:
          - download: current
            artifact: timeline

          - script: |
              rm -rf /var/timeline/*
              cp -r $PIPELINE_WORKSPACE/timeline/. /var/timeline/
              sudo systemctl restart timeline.service
            displayName: 'Copy Files and Restart Service'