-
Notifications
You must be signed in to change notification settings - Fork 3
/
azure-pipelines.yml
82 lines (67 loc) · 2.67 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
pool:
vmImage: 'windows-latest'
name: $(SourceBranchName)+1.$(Date:yyyy.MM)$(Rev:.r)
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_Solution-Packager'
projectName: 'Solution-Packager'
- task: NuGetToolInstaller@0
inputs:
versionSpec: '4.9.x'
displayName: 'Install NuGet 4.9.x'
- task: NuGetCommand@2
displayName: 'Restoring NuGet packages'
inputs:
command: 'restore'
restoreSolution: '**/*.sln'
feedsToUse: 'select'
- task: MSBuild@1
inputs:
solution: '**/*.sln'
configuration: $(MyVars.configuration)
msbuildArguments: '/p:Version=$(MyVars.BuildNumber)'
displayName: 'Building Solution'
- 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)
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.SolutionPackager\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'))