|
| 1 | +name: $(BuildID)_$(BuildDefinitionName)_$(SourceBranchName)_$(Date:yyyyMMdd)$(Rev:.r) |
| 2 | +resources: |
| 3 | +- repo: self |
| 4 | + clean: true |
| 5 | +phases: |
| 6 | + |
| 7 | +### Linux build ### |
| 8 | +- phase: LINUX |
| 9 | + displayName: Linux |
| 10 | + |
| 11 | + condition: succeeded() |
| 12 | + queue: |
| 13 | + name: Hosted Ubuntu 1604 |
| 14 | + timeoutInMinutes: 180 |
| 15 | + steps: |
| 16 | + |
| 17 | + - task: Docker@1 |
| 18 | + displayName: 'Start TPM Simulator' |
| 19 | + inputs: |
| 20 | + containerregistrytype: 'Container Registry' |
| 21 | + |
| 22 | + command: 'Run an image' |
| 23 | + |
| 24 | + imageName: aziotbld/testtpm |
| 25 | + |
| 26 | + containerName: 'testtpm-instance' |
| 27 | + |
| 28 | + ports: | |
| 29 | + 127.0.0.1:2321:2321 |
| 30 | + 127.0.0.1:2322:2322 |
| 31 | +
|
| 32 | + restartPolicy: unlessStopped |
| 33 | + |
| 34 | + - script: | |
| 35 | + # Run dotnet first experience. |
| 36 | + dotnet new |
| 37 | + |
| 38 | + # List active docker containers |
| 39 | + docker ps -a |
| 40 | + |
| 41 | + # Start build |
| 42 | + vsts/linux_csharp_netcore.sh |
| 43 | + displayName: build |
| 44 | + env: |
| 45 | + IOTHUB_CONN_STRING_CSHARP: $(IOTHUB-CONN-STRING-CSHARP) |
| 46 | + IOTHUB_PFX_X509_THUMBPRINT: $(IOTHUB-PFX-X509-THUMBPRINT) |
| 47 | + IOTHUB_X509_PFX_CERTIFICATE: $(IOTHUB-X509-PFX-CERTIFICATE) |
| 48 | + IOTHUB_EVENTHUB_CONN_STRING_CSHARP: $(IOTHUB-EVENTHUB-CONN-STRING-CSHARP) |
| 49 | + IOTHUB_EVENTHUB_COMPATIBLE_NAME: $(IOTHUB-EVENTHUB-COMPATIBLE-NAME) |
| 50 | + IOTHUB_EVENTHUB_CONSUMER_GROUP: $(IOTHUB-EVENTHUB-CONSUMER-GROUP) |
| 51 | + DPS_IDSCOPE: $(DPS-IDSCOPE) |
| 52 | + DPS_GLOBALDEVICEENDPOINT: $(DPS-GLOBALDEVICEENDPOINT) |
| 53 | + DPS_INDIVIDUALX509_PFX_CERTIFICATE: $(DPS-INDIVIDUALX509-PFX-CERTIFICATE) |
| 54 | + DPS_GROUPX509_PFX_CERTIFICATE: $(DPS-GROUPX509-PFX-CERTIFICATE) |
| 55 | + DPS_X509_PFX_CERTIFICATE_PASSWORD: $(DPS-X509-PFX-CERTIFICATE-PASSWORD) |
| 56 | + DPS_GROUPX509_CERTIFICATE_CHAIN: $(DPS-GROUPX509-CERTIFICATE-CHAIN) |
| 57 | + DPS_TPM_REGISTRATIONID: $(DPS-TPM-REGISTRATIONID) |
| 58 | + DPS_TPM_DEVICEID: $(DPS-TPM-DEVICEID) |
| 59 | + PROVISIONING_CONNECTION_STRING: $(PROVISIONING-CONNECTION-STRING) |
| 60 | + IOTHUB_DEVICE_CONN_STRING_INVALIDCERT: $(IOTHUB-DEVICE-CONN-STRING-INVALIDCERT) |
| 61 | + IOTHUB_CONN_STRING_INVALIDCERT: $(IOTHUB-CONN-STRING-INVALIDCERT) |
| 62 | + DPS_GLOBALDEVICEENDPOINT_INVALIDCERT: $(DPS-GLOBALDEVICEENDPOINT-INVALIDCERT) |
| 63 | + PROVISIONING_CONNECTION_STRING_INVALIDCERT: $(PROVISIONING-CONNECTION-STRING-INVALIDCERT) |
| 64 | + FAR_AWAY_IOTHUB_HOSTNAME: $(FAR-AWAY-IOTHUB-HOSTNAME) |
| 65 | + CUSTOM_ALLOCATION_POLICY_WEBHOOK: $(CUSTOM-ALLOCATION-POLICY-WEBHOOK) |
| 66 | + IOTHUB_PROXY_SERVER_ADDRESS: 127.0.0.1:8888 |
| 67 | +
|
| 68 | + - task: CopyFiles@2 |
| 69 | + displayName: 'Copy files to the artifacts folder' |
| 70 | + inputs: |
| 71 | + SourceFolder: '$(Build.SourcesDirectory)' |
| 72 | + |
| 73 | + Contents: '**/*.trx' |
| 74 | + |
| 75 | + TargetFolder: '$(Build.ArtifactStagingDirectory)' |
| 76 | + |
| 77 | + condition: always() |
| 78 | + |
| 79 | + - task: PublishBuildArtifacts@1 |
| 80 | + displayName: 'Publish Artifact: testresults_linux' |
| 81 | + inputs: |
| 82 | + ArtifactName: testresults_linux |
| 83 | + |
| 84 | + condition: always() |
| 85 | + |
| 86 | + - task: PublishTestResults@2 |
| 87 | + displayName: 'Publish Test Results **/*.trx' |
| 88 | + inputs: |
| 89 | + testRunner: VSTest |
| 90 | + testRunTitle: 'Linux Tests' |
| 91 | + testResultsFiles: '**/*.trx' |
| 92 | + |
| 93 | + condition: always() |
| 94 | + |
| 95 | +### Windows build ### |
| 96 | + |
| 97 | +- phase: WINDOWS |
| 98 | + displayName: Windows |
| 99 | +# Uncomment to serialize builds: |
| 100 | +# dependsOn: LINUX |
| 101 | + |
| 102 | + condition: succeeded() |
| 103 | + queue: |
| 104 | + name: Hosted VS2017 |
| 105 | + timeoutInMinutes: 180 |
| 106 | + steps: |
| 107 | + |
| 108 | + - script: | |
| 109 | + rem Run dotnet first experience. |
| 110 | + dotnet new |
| 111 | + |
| 112 | + rem List active docker containers |
| 113 | + docker ps -a |
| 114 | +
|
| 115 | + rem Start |
| 116 | +
|
| 117 | + rem Start ETL logging |
| 118 | + logman create trace IotTrace -o iot.etl -pf tools/CaptureLogs/iot_providers.txt |
| 119 | + logman start IotTrace |
| 120 | + |
| 121 | + rem Start build |
| 122 | + vsts/windows_csharp.cmd |
| 123 | +
|
| 124 | + ren Stop ETL logging |
| 125 | + logman stop IotTrace |
| 126 | + logman delete IotTrace |
| 127 | + |
| 128 | + displayName: build |
| 129 | + env: |
| 130 | + IOTHUB_CONN_STRING_CSHARP: $(IOTHUB-CONN-STRING-CSHARP) |
| 131 | + IOTHUB_PFX_X509_THUMBPRINT: $(IOTHUB-PFX-X509-THUMBPRINT) |
| 132 | + IOTHUB_X509_PFX_CERTIFICATE: $(IOTHUB-X509-PFX-CERTIFICATE) |
| 133 | + IOTHUB_EVENTHUB_CONN_STRING_CSHARP: $(IOTHUB-EVENTHUB-CONN-STRING-CSHARP) |
| 134 | + IOTHUB_EVENTHUB_COMPATIBLE_NAME: $(IOTHUB-EVENTHUB-COMPATIBLE-NAME) |
| 135 | + IOTHUB_EVENTHUB_CONSUMER_GROUP: $(IOTHUB-EVENTHUB-CONSUMER-GROUP) |
| 136 | + DPS_IDSCOPE: $(DPS-IDSCOPE) |
| 137 | + DPS_GLOBALDEVICEENDPOINT: $(DPS-GLOBALDEVICEENDPOINT) |
| 138 | + DPS_INDIVIDUALX509_PFX_CERTIFICATE: $(DPS-INDIVIDUALX509-PFX-CERTIFICATE) |
| 139 | + DPS_GROUPX509_PFX_CERTIFICATE: $(DPS-GROUPX509-PFX-CERTIFICATE) |
| 140 | + DPS_X509_PFX_CERTIFICATE_PASSWORD: $(DPS-X509-PFX-CERTIFICATE-PASSWORD) |
| 141 | + DPS_GROUPX509_CERTIFICATE_CHAIN: $(DPS-GROUPX509-CERTIFICATE-CHAIN) |
| 142 | + DPS_TPM_REGISTRATIONID: $(DPS-TPM-REGISTRATIONID) |
| 143 | + DPS_TPM_DEVICEID: $(DPS-TPM-DEVICEID) |
| 144 | + PROVISIONING_CONNECTION_STRING: $(PROVISIONING-CONNECTION-STRING) |
| 145 | + IOTHUB_DEVICE_CONN_STRING_INVALIDCERT: $(IOTHUB-DEVICE-CONN-STRING-INVALIDCERT) |
| 146 | + IOTHUB_CONN_STRING_INVALIDCERT: $(IOTHUB-CONN-STRING-INVALIDCERT) |
| 147 | + DPS_GLOBALDEVICEENDPOINT_INVALIDCERT: $(DPS-GLOBALDEVICEENDPOINT-INVALIDCERT) |
| 148 | + PROVISIONING_CONNECTION_STRING_INVALIDCERT: $(PROVISIONING-CONNECTION-STRING-INVALIDCERT) |
| 149 | + FAR_AWAY_IOTHUB_HOSTNAME: $(FAR-AWAY-IOTHUB-HOSTNAME) |
| 150 | + CUSTOM_ALLOCATION_POLICY_WEBHOOK: $(CUSTOM-ALLOCATION-POLICY-WEBHOOK) |
| 151 | + IOTHUB_PROXY_SERVER_ADDRESS: 127.0.0.1:3128 |
| 152 | +
|
| 153 | + - task: CopyFiles@2 |
| 154 | + displayName: 'Copy TRX files to the artifacts folder' |
| 155 | + inputs: |
| 156 | + SourceFolder: '$(Build.SourcesDirectory)' |
| 157 | + |
| 158 | + Contents: '**/*.trx' |
| 159 | + |
| 160 | + TargetFolder: '$(Build.ArtifactStagingDirectory)' |
| 161 | + |
| 162 | + condition: always() |
| 163 | + |
| 164 | + - task: CopyFiles@2 |
| 165 | + displayName: 'Copy ETL files to the artifacts folder' |
| 166 | + inputs: |
| 167 | + SourceFolder: '$(Build.SourcesDirectory)' |
| 168 | + |
| 169 | + Contents: '**/*.etl' |
| 170 | + |
| 171 | + TargetFolder: '$(Build.ArtifactStagingDirectory)' |
| 172 | + |
| 173 | + condition: always() |
| 174 | + |
| 175 | + - task: PublishBuildArtifacts@1 |
| 176 | + displayName: 'Publish Artifact: testresults' |
| 177 | + inputs: |
| 178 | + ArtifactName: testresults_windows |
| 179 | + |
| 180 | + condition: always() |
| 181 | + |
| 182 | + - task: PublishTestResults@2 |
| 183 | + displayName: 'Publish Test Results **/*.trx' |
| 184 | + inputs: |
| 185 | + testRunner: VSTest |
| 186 | + |
| 187 | + testResultsFiles: '**/*.trx' |
| 188 | + |
| 189 | + testRunTitle: 'Windows Tests' |
| 190 | + |
| 191 | + platform: Windows |
| 192 | + |
| 193 | + configuration: 'Debug UT + Release E2E' |
| 194 | + |
| 195 | + condition: always() |
| 196 | + |
| 197 | +### WINDOWS Analyzers ### |
| 198 | +- phase: Analyzers |
| 199 | + displayName: Analyzers |
| 200 | + |
| 201 | + condition: succeeded() |
| 202 | + queue: |
| 203 | + name: Hosted VS2017 |
| 204 | + timeoutInMinutes: 60 |
| 205 | + steps: |
| 206 | + |
| 207 | + - script: | |
| 208 | + rem Run dotnet first experience. |
| 209 | + dotnet new |
| 210 | +
|
| 211 | + rem Start build |
| 212 | + build.cmd -clean -nounittests -configuration Debug |
| 213 | +
|
| 214 | + displayName: build |
| 215 | +
|
| 216 | + - task: ComponentGovernanceComponentDetection@0 |
| 217 | + displayName: 'Component Detection' |
| 218 | + |
| 219 | + |
| 220 | + - task: securedevelopmentteam.vss-secure-development-tools.build-task-antimalware.AntiMalware@3 |
| 221 | + displayName: 'Run MpCmdRun.exe' |
| 222 | + inputs: |
| 223 | + EnableServices: true |
| 224 | + SignatureFreshness: OneDay |
| 225 | + |
| 226 | + |
| 227 | + |
| 228 | + - task: securedevelopmentteam.vss-secure-development-tools.build-task-autoapplicability.AutoApplicability@1 |
| 229 | + displayName: 'Run AutoApplicability' |
| 230 | + inputs: |
| 231 | + ExternalRelease: true |
| 232 | + |
| 233 | + IsSoftware: true |
| 234 | + |
| 235 | + UsesHSM: true |
| 236 | + |
| 237 | + - task: securedevelopmentteam.vss-secure-development-tools.build-task-binskim.BinSkim@3 |
| 238 | + displayName: 'Run BinSkim ' |
| 239 | + inputs: |
| 240 | + arguments: 'analyze $(Build.SourcesDirectory)\Microsoft.Azure.Devices.*.dll $(Build.SourcesDirectory)\DeviceExplorer.exe --recurse --verbose' |
| 241 | + |
| 242 | + # TODO #181 Config issue: must run on Debug builds only with valid PDBs. |
| 243 | + enabled: false |
| 244 | + |
| 245 | + - task: securedevelopmentteam.vss-secure-development-tools.build-task-codemetrics.CodeMetrics@1 |
| 246 | + displayName: 'Run CodeMetrics ' |
| 247 | + inputs: |
| 248 | + Files: '$(Build.SourcesDirectory)\**\DeviceExplorer.exe;$(Build.SourcesDirectory)\**\Microsoft.Azure.Devices.*.dll' |
| 249 | + |
| 250 | + # TODO #181 Config issue: must run on Debug builds only with valid PDBs. |
| 251 | + enabled: false |
| 252 | + |
| 253 | + |
| 254 | + - task: securedevelopmentteam.vss-secure-development-tools.build-task-credscan.CredScan@2 |
| 255 | + displayName: 'Run CredScan' |
| 256 | + inputs: |
| 257 | + suppressionsFile: vsts/CredScanSuppressions.json |
| 258 | + regexMatchTimeoutInSeconds: 5 |
| 259 | + |
| 260 | + # TODO #181 Samples / tests fail the test due to fake connection strings. |
| 261 | + debugMode: false |
| 262 | + |
| 263 | + - task: securedevelopmentteam.vss-secure-development-tools.build-task-policheck.PoliCheck@1 |
| 264 | + displayName: 'Run PoliCheck' |
| 265 | + inputs: |
| 266 | + targetType: F |
| 267 | + |
| 268 | + - task: securedevelopmentteam.vss-secure-development-tools.build-task-vulnerabilityassessment.VulnerabilityAssessment@0 |
| 269 | + displayName: 'Run Vulnerability Assessment' |
| 270 | + |
| 271 | + - task: securedevelopmentteam.vss-secure-development-tools.build-task-publishsecurityanalysislogs.PublishSecurityAnalysisLogs@2 |
| 272 | + displayName: 'Publish Security Analysis Logs' |
| 273 | + |
| 274 | + - task: securedevelopmentteam.vss-secure-development-tools.build-task-report.SdtReport@1 |
| 275 | + displayName: 'Create Security Analysis Report' |
| 276 | + inputs: |
| 277 | + AllTools: true |
| 278 | + |
| 279 | + - task: securedevelopmentteam.vss-secure-development-tools.build-task-uploadtotsa.TSAUpload@1 |
| 280 | + displayName: 'TSA upload' |
| 281 | + inputs: |
| 282 | + tsaVersion: TsaV2 |
| 283 | + tsaStamp: Azure |
| 284 | + codeBaseName: 'Azure-Iot-SDK-CSharp-Master' |
| 285 | + |
| 286 | + - task: securedevelopmentteam.vss-secure-development-tools.build-task-postanalysis.PostAnalysis@1 |
| 287 | + displayName: 'Post Analysis' |
| 288 | + inputs: |
| 289 | + AllTools: true |
| 290 | + |
| 291 | + # TODO #181 Enable post analysis to break builds after all above items are enabled. |
| 292 | + enabled: false |
| 293 | + |
| 294 | +# END: SDL and Compliance tasks # |
0 commit comments