|
| 1 | +# Build pipeline v2 (Containerised) |
| 2 | + |
| 3 | +resources: |
| 4 | + repositories: |
| 5 | + - repository: MockRegister |
| 6 | + type: git |
| 7 | + name: sb-mock-register |
| 8 | + ref: develop |
| 9 | + - repository: MockDataHolder |
| 10 | + type: git |
| 11 | + name: sb-mock-data-holder |
| 12 | + ref: develop |
| 13 | + - repository: MockDataHolder-Energy |
| 14 | + type: git |
| 15 | + name: sb-mock-data-holder-energy |
| 16 | + ref: develop |
| 17 | + |
| 18 | +trigger: |
| 19 | + - develop |
| 20 | + |
| 21 | +pool: |
| 22 | + vmImage: ubuntu-latest |
| 23 | + |
| 24 | +steps: |
| 25 | + |
| 26 | +# Checkout repositories |
| 27 | +- checkout: MockRegister |
| 28 | +- checkout: MockDataHolder |
| 29 | +- checkout: MockDataHolder-Energy |
| 30 | +- checkout: self |
| 31 | + |
| 32 | +# Build mock-register |
| 33 | +- task: Docker@2 |
| 34 | + displayName: Build mock-register image |
| 35 | + inputs: |
| 36 | + command: build |
| 37 | + Dockerfile: $(Build.SourcesDirectory)/sb-mock-register/Source/Dockerfile |
| 38 | + buildContext: $(Build.SourcesDirectory)/sb-mock-register/Source |
| 39 | + repository: mock-register |
| 40 | + tags: latest |
| 41 | + |
| 42 | +# Build mock-data-holder |
| 43 | +- task: Docker@2 |
| 44 | + displayName: Build mock-data-holder image |
| 45 | + inputs: |
| 46 | + command: build |
| 47 | + Dockerfile: $(Build.SourcesDirectory)/sb-mock-data-holder/Source/Dockerfile |
| 48 | + buildContext: $(Build.SourcesDirectory)/sb-mock-data-holder/Source |
| 49 | + repository: mock-data-holder |
| 50 | + tags: latest |
| 51 | + |
| 52 | +# Build mock-data-holder-energy |
| 53 | +- task: Docker@2 |
| 54 | + displayName: Build mock-data-holder-energy image |
| 55 | + inputs: |
| 56 | + command: build |
| 57 | + Dockerfile: $(Build.SourcesDirectory)/sb-mock-data-holder-energy/Source/Dockerfile |
| 58 | + buildContext: $(Build.SourcesDirectory)/sb-mock-data-holder-energy/Source |
| 59 | + repository: mock-data-holder-energy |
| 60 | + tags: latest |
| 61 | + |
| 62 | +# Build mock-data-recipient |
| 63 | +- task: Docker@2 |
| 64 | + displayName: Build mock-data-recipient image |
| 65 | + inputs: |
| 66 | + command: build |
| 67 | + Dockerfile: $(Build.SourcesDirectory)/sb-mock-data-recipient/Source/Dockerfile |
| 68 | + buildContext: $(Build.SourcesDirectory)/sb-mock-data-recipient/Source |
| 69 | + repository: mock-data-recipient |
| 70 | + tags: latest |
| 71 | + |
| 72 | +# Build mock-data-recipient-unit-tests |
| 73 | +- task: Docker@2 |
| 74 | + displayName: Build mock-data-recipient-unit-tests image |
| 75 | + inputs: |
| 76 | + command: build |
| 77 | + Dockerfile: $(Build.SourcesDirectory)/sb-mock-data-recipient/Source/Dockerfile.unit-tests |
| 78 | + buildContext: $(Build.SourcesDirectory)/sb-mock-data-recipient/Source |
| 79 | + repository: mock-data-recipient-unit-tests |
| 80 | + tags: latest |
| 81 | + |
| 82 | +# Build mock-data-recipient-integration-tests |
| 83 | +- task: Docker@2 |
| 84 | + displayName: Build mock-data-recipient-integration-tests image |
| 85 | + inputs: |
| 86 | + command: build |
| 87 | + Dockerfile: $(Build.SourcesDirectory)/sb-mock-data-recipient/Source/Dockerfile.integration-tests |
| 88 | + buildContext: $(Build.SourcesDirectory)/sb-mock-data-recipient/Source |
| 89 | + repository: mock-data-recipient-integration-tests |
| 90 | + tags: latest |
| 91 | + |
| 92 | +# Build mock-data-recipient-e2e-tests |
| 93 | +- task: Docker@2 |
| 94 | + displayName: Build mock-data-recipient-e2e-tests image |
| 95 | + inputs: |
| 96 | + command: build |
| 97 | + Dockerfile: $(Build.SourcesDirectory)/sb-mock-data-recipient/Source/Dockerfile.e2e-tests |
| 98 | + buildContext: $(Build.SourcesDirectory)/sb-mock-data-recipient/Source |
| 99 | + repository: mock-data-recipient-e2e-tests |
| 100 | + tags: latest |
| 101 | + |
| 102 | +# List docker images |
| 103 | +- task: Docker@2 |
| 104 | + displayName: List Docker images |
| 105 | + condition: always() |
| 106 | + inputs: |
| 107 | + command: images |
| 108 | + |
| 109 | +# Run unit tests |
| 110 | +- task: DockerCompose@0 |
| 111 | + displayName: Unit tests - Up |
| 112 | + inputs: |
| 113 | + action: Run a Docker Compose command |
| 114 | + dockerComposeFile: $(Build.SourcesDirectory)/sb-mock-data-recipient/Source/docker-compose.UnitTests.yml |
| 115 | + dockerComposeCommand: up --abort-on-container-exit --exit-code-from mock-data-recipient-unit-tests |
| 116 | + |
| 117 | +# Remove unit tests |
| 118 | +- task: DockerCompose@0 |
| 119 | + displayName: Unit tests - Down |
| 120 | + condition: always() |
| 121 | + inputs: |
| 122 | + action: Run a Docker Compose command |
| 123 | + dockerComposeFile: $(Build.SourcesDirectory)/sb-mock-data-recipient/Source/docker-compose.UnitTests.yml |
| 124 | + dockerComposeCommand: down |
| 125 | + |
| 126 | +# Run integration tests |
| 127 | +- task: DockerCompose@0 |
| 128 | + displayName: Integration tests - Up |
| 129 | + condition: always() |
| 130 | + inputs: |
| 131 | + action: Run a Docker Compose command |
| 132 | + dockerComposeFile: $(Build.SourcesDirectory)/sb-mock-data-recipient/Source/docker-compose.IntegrationTests.yml |
| 133 | + dockerComposeCommand: up --abort-on-container-exit --exit-code-from mock-data-recipient-integration-tests |
| 134 | + |
| 135 | +# Remove integration tests |
| 136 | +- task: DockerCompose@0 |
| 137 | + displayName: Integration tests - Down |
| 138 | + condition: always() |
| 139 | + inputs: |
| 140 | + action: Run a Docker Compose command |
| 141 | + dockerComposeFile: $(Build.SourcesDirectory)/sb-mock-data-recipient/Source/docker-compose.IntegrationTests.yml |
| 142 | + dockerComposeCommand: down |
| 143 | + |
| 144 | +# Run e2e tests |
| 145 | +- task: DockerCompose@0 |
| 146 | + displayName: E2E tests - Up |
| 147 | + condition: always() |
| 148 | + inputs: |
| 149 | + action: Run a Docker Compose command |
| 150 | + dockerComposeFile: $(Build.SourcesDirectory)/sb-mock-data-recipient/Source/docker-compose.E2ETests.yml |
| 151 | + dockerComposeCommand: up --abort-on-container-exit --exit-code-from mock-data-recipient-e2e-tests |
| 152 | + |
| 153 | +# Remove e2e tests |
| 154 | +- task: DockerCompose@0 |
| 155 | + displayName: E2E tests - Down |
| 156 | + condition: always() |
| 157 | + inputs: |
| 158 | + action: Run a Docker Compose command |
| 159 | + dockerComposeFile: $(Build.SourcesDirectory)/sb-mock-data-recipient/Source/docker-compose.E2ETests.yml |
| 160 | + dockerComposeCommand: down |
| 161 | + |
| 162 | +# Save docker image to TAR so it can be published |
| 163 | +- task: Docker@2 |
| 164 | + displayName: Save MockDataRecipient image to TAR |
| 165 | + # condition: always() |
| 166 | + inputs: |
| 167 | + repository: mock-data-recipient |
| 168 | + command: save |
| 169 | + arguments: --output $(build.artifactstagingdirectory)/mock-data-recipient.image.tar mock-data-recipient |
| 170 | + addPipelineData: false |
| 171 | + |
| 172 | +# Publish docker image |
| 173 | +- task: PublishPipelineArtifact@1 |
| 174 | + displayName: Publish container images |
| 175 | + # condition: always() |
| 176 | + inputs: |
| 177 | + path: $(build.artifactstagingdirectory) |
| 178 | + artifact: Container Images |
| 179 | + |
| 180 | +# Publish mock-register logs |
| 181 | +- publish: $(Build.SourcesDirectory)/sb-mock-data-recipient/Source/_temp/mock-register/tmp |
| 182 | + displayName: Publish MockRegister logs |
| 183 | + condition: always() |
| 184 | + artifact: Mock-Register - Logs |
| 185 | + |
| 186 | +# Publish mock-data-holder logs |
| 187 | +- publish: $(Build.SourcesDirectory)/sb-mock-data-recipient/Source/_temp/mock-data-holder/tmp |
| 188 | + displayName: Publish MockDataHolder logs |
| 189 | + condition: always() |
| 190 | + artifact: Mock-Data-Holder - Logs |
| 191 | + |
| 192 | +# Publish mock-data-holder-energy logs |
| 193 | +- publish: $(Build.SourcesDirectory)/sb-mock-data-recipient/Source/_temp/mock-data-holder-energy/tmp |
| 194 | + displayName: Publish MockDataHolder-Energy logs |
| 195 | + condition: always() |
| 196 | + artifact: Mock-Data-Holder-Energy - Logs |
| 197 | + |
| 198 | +# Publish mock-data-recipient logs |
| 199 | +- publish: $(Build.SourcesDirectory)/sb-mock-data-recipient/Source/_temp/mock-data-recipient/tmp |
| 200 | + displayName: Publish MockDataRecipient logs |
| 201 | + condition: always() |
| 202 | + artifact: Mock-Data-Recipient - Logs |
| 203 | + |
| 204 | +# Publish mock-data-recipient unit tests results |
| 205 | +- publish: $(Build.SourcesDirectory)/sb-mock-data-recipient/Source/_temp/mock-data-recipient-unit-tests/testresults |
| 206 | + displayName: Publish unit tests |
| 207 | + condition: always() |
| 208 | + artifact: Mock-Data-Recipient - Unit tests |
| 209 | + |
| 210 | +# Publish mock-data-recipient integration tests results |
| 211 | +- publish: $(Build.SourcesDirectory)/sb-mock-data-recipient/Source/_temp/mock-data-recipient-integration-tests/testresults |
| 212 | + displayName: Publish integration tests |
| 213 | + condition: always() |
| 214 | + artifact: Mock-Data-Recipient - Integration tests |
| 215 | + |
| 216 | +# Publish mock-data-recipient e2e tests results |
| 217 | +- publish: $(Build.SourcesDirectory)/sb-mock-data-recipient/Source/_temp/mock-data-recipient-e2e-tests/testresults |
| 218 | + displayName: Publish e2e tests |
| 219 | + condition: always() |
| 220 | + artifact: Mock-Data-Recipient - E2E tests |
| 221 | + |
| 222 | +# TODO - MJS - Run formatter over TRX to produce formatted report suitable for attaching to Devops US & publish as artifact |
| 223 | + |
| 224 | +- task: UseDotNet@2 |
| 225 | + displayName: 'Use .NET 6 sdk' |
| 226 | + condition: always() |
| 227 | + inputs: |
| 228 | + packageType: sdk |
| 229 | + version: '6.0.x' |
| 230 | + performMultiLevelLookup: true |
| 231 | + |
| 232 | +- task: CmdLine@2 |
| 233 | + displayName: 'Install dotnet-ef' |
| 234 | + condition: always() |
| 235 | + inputs: |
| 236 | + script: 'dotnet tool install --global dotnet-ef' |
| 237 | + |
| 238 | +- task: CmdLine@2 |
| 239 | + displayName: 'Check dotnet-ef version' |
| 240 | + condition: always() |
| 241 | + inputs: |
| 242 | + script: 'dotnet-ef' |
| 243 | + |
| 244 | +- script: | |
| 245 | + cd $(Build.SourcesDirectory)/sb-mock-data-recipient/Source/CDR.DataRecipient.Repository.SQL |
| 246 | + dotnet ef migrations bundle --context RecipientDatabaseContext --verbose --self-contained |
| 247 | + ls |
| 248 | + displayName: 'Run EF Migrations bundle' |
| 249 | + condition: always() |
| 250 | + |
| 251 | +- publish: $(Build.SourcesDirectory)/sb-mock-data-recipient/Source/CDR.DataRecipient.Repository.SQL/efbundle |
| 252 | + displayName: Publish EF Migration bundle |
| 253 | + condition: always() |
| 254 | + artifact: Database Migration Scripts |
0 commit comments