forked from albanian-xrm/Early-Bound
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathazure-pipelines.yml
162 lines (137 loc) · 5.37 KB
/
azure-pipelines.yml
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
pool:
vmImage: 'windows-2019'
name: $(SourceBranchName)+1.$(Date:yyyy.MM)$(Rev:.r)
variables:
disable.coverage.autogenerate: 'true'
steps:
- script: echo Starting build pipeline!
displayName: 'Hello from Albanian Xrm'
- powershell: |
echo "##vso[task.setvariable variable=configuration;isOutput=true]$(IF($env:BRANCH -eq "refs/heads/main"){"Azure Pipelines"}else{"release"})"
echo "##vso[task.setvariable variable=BuildNumber;isOutput=true]$(($env:BuildNumber).Substring(($env:BuildNumber).LastIndexOf('+')+1))"
name: MyVars
env:
BRANCH: $(Build.SourceBranch)
BuildNumber: $(Build.BuildNumber)
displayName: 'Set Configuration Variable'
- task: SonarCloudPrepare@1
condition: eq(variables['Build.SourceBranch'], 'refs/heads/main')
inputs:
SonarCloud: 'AlbanianXrm SonarCloud'
organization: 'albanian-xrm'
scannerMode: 'MSBuild'
projectKey: 'albanian-xrm_Early-Bound'
projectName: 'Early-Bound'
- task: NuGetCommand@2
displayName: 'Restoring NuGet packages'
inputs:
command: 'restore'
restoreSolution: '**/*.sln'
feedsToUse: 'select'
- task: DownloadSecureFile@1
name: TestSignKey
inputs:
secureFile: 'AlbanianXrm.Tests.snk'
condition: eq(variables['Build.SourceBranch'], 'refs/heads/main')
displayName: 'Tests Secret'
- task: DownloadSecureFile@1
name: SignKey
inputs:
secureFile: 'AlbanianXrm.EarlyBound.snk'
condition: eq(variables['Build.SourceBranch'], 'refs/heads/main')
displayName: 'Secret'
- task: DownloadSecureFile@1
name: MyPlugin
inputs:
secureFile: 'SecretKeeper.cs'
condition: eq(variables['Build.SourceBranch'], 'refs/heads/main')
displayName: 'Syncfusion Secret'
- powershell: echo "##vso[task.setvariable variable=Path;isOutput=true]$((get-item $env:SECURE_FILE).Directory.FullName)"
name: secretFolder
env:
Secure_File: $(TestSignKey.secureFilePath)
condition: eq(variables['Build.SourceBranch'], 'refs/heads/main')
displayName: 'Secret folder'
- task: CopyFiles@2
inputs:
sourceFolder: $(secretFolder.Path)
contents: 'AlbanianXrm.Tests.snk'
targetFolder: 'AlbanianXrm.CrmSvcUtilExtensions.Tests'
overWrite: true
condition: eq(variables['Build.SourceBranch'], 'refs/heads/main')
displayName: 'Overwrite AlbanianXrm.CrmSvcUtilExtensions.Tests SignKey'
- task: CopyFiles@2
inputs:
sourceFolder: $(secretFolder.Path)
contents: 'AlbanianXrm.EarlyBound.snk'
targetFolder: 'AlbanianXrm.CrmSvcUtilExtensions'
overWrite: true
condition: eq(variables['Build.SourceBranch'], 'refs/heads/main')
displayName: 'Overwrite AlbanianXrm.CrmSvcUtilExtensions SignKey'
- task: CopyFiles@2
inputs:
sourceFolder: $(secretFolder.Path)
contents: 'SecretKeeper.cs'
targetFolder: 'AlbanianXrm.EarlyBound'
overWrite: true
condition: eq(variables['Build.SourceBranch'], 'refs/heads/main')
displayName: 'Overwrite AlbanianXrm.EarlyBound Syncfusion Secret'
- task: MSBuild@1
inputs:
solution: '**/*.sln'
configuration: '$(MyVars.configuration)'
msbuildArguments: '/p:Version=$(MyVars.BuildNumber)'
displayName: 'Building Solution'
- task: VSTest@2
inputs:
testSelector: 'testAssemblies'
testAssemblyVer2: |
**\*Tests.dll
!**\*TestAdapter.dll
!**\obj\**
searchFolder: '$(System.DefaultWorkingDirectory)'
testRunTitle: 'Unit Tests'
platform: 'AnyCPU'
configuration: $(MyVars.configuration)
displayName: 'Running unit tests'
- task: MSBuild@1
inputs:
solution: 'AlbanianXrm.Coverage\AlbanianXrm.Coverage.csproj'
configuration: Debug
msbuildArguments: '/p:Version=$(MyVars.BuildNumber);AlbanianXrm-Coverage-Reports=Cobertura%3BHtmlInline_AzurePipelines%3BSonarQube'
displayName: 'Testing & Coverage'
- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: $(System.DefaultWorkingDirectory)/AlbanianXrm.Coverage/**/CoverageReport/Cobertura.xml
reportDirectory: $(System.DefaultWorkingDirectory)/AlbanianXrm.Coverage/**/CoverageReport
displayName: 'Publish Coverage'
- task: SonarCloudAnalyze@1
condition: eq(variables['Build.SourceBranch'], 'refs/heads/main')
- task: SonarCloudPublish@1
condition: eq(variables['Build.SourceBranch'], 'refs/heads/main')
inputs:
pollingTimeoutSec: '300'
- task: NuGetCommand@2
displayName: 'Creating NuGet package'
inputs:
command: 'pack'
packagesToPack: '**/*.nuspec'
packDestination: '$(Build.ArtifactStagingDirectory)/NuGet'
buildProperties: version=$(MyVars.BuildNumber);configuration=Release
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
- task: PublishBuildArtifacts@1
displayName: 'Publishing NuGet package to pipeline'
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)/NuGet'
artifactName: 'NuGet Package'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
- powershell: Compress-Archive -Path AlbanianXrm.EarlyBound\bin\Release\net462\XrmToolBox\Plugins\* -DestinationPath Plugins.zip
displayName: 'Create zip for GitHub'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
- task: PublishBuildArtifacts@1
displayName: 'Publishing NuGet package to pipeline'
inputs:
pathtoPublish: 'Plugins.zip'
artifactName: 'Plugin Package'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))