12
12
variables :
13
13
basePath : ' src/APIM_ARMTemplate'
14
14
configuration : ' Release'
15
+ BASE_VERSION : ' 0.0.1'
16
+ PREVIEW_LABEL : ' preview'
17
+ BUILD_NUMBER : $[counter(format('{0}_{1}_{2}', variables['BASE_VERSION'], variables['PREVIEW_LABEL'], variables['Build.SourceBranch']), 1)]
18
+ APP_VERSION : $[format('{0}-{1}.{2}', variables['BASE_VERSION'], variables['PREVIEW_LABEL'], variables['BUILD_NUMBER'])]
15
19
16
20
stages :
17
21
- stage : build
@@ -25,6 +29,27 @@ stages:
25
29
version : ' 3.1.x'
26
30
performMultiLevelLookup : true
27
31
32
+ - pwsh : |
33
+ $pr = "pr." + $env:SYSTEM_PULLREQUEST_PULLREQUESTNUMBER
34
+ $version = $env:BASE_VERSION + "-" + $pr + "." + $env:BUILD_NUMBER
35
+ Write-Host "Preview label: $pr"
36
+ Write-Host "NuGet version: $nuget"
37
+ Write-Host "##vso[task.setvariable variable=PREVIEW_LABEL]$pr"
38
+ Write-Host "##vso[task.setvariable variable=APP_VERSION]$version"
39
+ displayName: Override version for PRs
40
+ condition: eq(variables['Build.Reason'], 'PullRequest')
41
+
42
+ - pwsh : |
43
+ $tagVersion = $env:BUILD_SOURCEBRANCHNAME
44
+ Write-Host "Tag version: $tagVersion"
45
+ Write-Host "##vso[task.setvariable variable=APP_VERSION]$tagVersion"
46
+ displayName: Override version for tags
47
+ condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/')
48
+
49
+ - pwsh : |
50
+ Write-Host "##vso[build.updatebuildnumber]$env:APP_VERSION"
51
+ displayName: Update the build number with a more readable one
52
+
28
53
- task : DotNetCoreCLI@2
29
54
displayName : ' Build Toolkit'
30
55
inputs :
@@ -49,3 +74,50 @@ stages:
49
74
inputs :
50
75
pathToPublish : ' $(basePath)/apimtemplate/bin/$(configuration)'
51
76
artifactName : build
77
+
78
+ - stage : postbuild
79
+ displayName : ' Post Build Checks'
80
+ condition : eq('ref/heads/main', variables['Build.SourceBranch'])
81
+ dependsOn : ['build']
82
+ jobs :
83
+ - job : required_checks
84
+ displayName : ' Run required code checks'
85
+ steps :
86
+ - pwsh : |
87
+ $repo = "$(Build.Repository.Id)"
88
+ $repo = $repo.Substring($repo.IndexOf("/") + 1)
89
+ $branch = "main"
90
+ $CODEBASE_NAME = $repo + "_" + $branch
91
+ echo "Using codebase: $CODEBASE_NAME"
92
+ Write-Host "##vso[task.setvariable variable=CODEBASE_NAME]$CODEBASENAME"
93
+
94
+ - task : CredScan@2
95
+ inputs :
96
+ toolMajorVersion : ' V2'
97
+
98
+ - task : PoliCheck@1
99
+ inputs :
100
+ inputType : ' Basic'
101
+ targetType : ' F'
102
+
103
+ - task : SdtReport@1
104
+ displayName : ' Create security analysis report'
105
+ inputs :
106
+ AllTools : false
107
+ APIScan : false
108
+ BinSkim : false
109
+ CodesignValidation : false
110
+ CredScan : true
111
+ FortifySCA : false
112
+ FxCop : false
113
+ ModernCop : false
114
+ MSRD : false
115
+ PoliCheck : true
116
+ RoslynAnalyzers : false
117
+ SDLNativeRules : false
118
+ Semmle : false
119
+ TSLint : false
120
+ ToolLogsNotFoundAction : ' Standard'
121
+
122
+ - task : PublishSecurityAnalysisLogs@3
123
+ displayName : ' Publish security analysis logs'
0 commit comments