-
Notifications
You must be signed in to change notification settings - Fork 19
/
azure-pipelines.yml
135 lines (116 loc) · 4.33 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
pool:
name: Hosted VS2017
trigger:
batch: true
branches:
include:
- '*'
paths:
exclude:
- README.md
pr:
branches:
include: [refs/heads/master]
paths:
exclude:
- README.md
steps:
- task: CopyFiles@2
displayName: 'Copy Files to Staging Directory'
inputs:
Contents: |
**\public\**
**\private\**
**\functions\**
**\classes\**
**\tests\**
*.ps1
*.psm1
*.psd1
license.md
readme.md
TargetFolder: '$(build.artifactstagingdirectory)\$(Build.DefinitionName)'
CleanTargetFolder: true
- task: GitVersion@4
displayName: GitVersion
inputs:
preferBundledVersion: false
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
- task: VersionPowerShellModule@2
displayName: 'Version PowerShell Modules'
inputs:
InjectVersion: true
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
- task: CopyFiles@2
displayName: 'Copy Files to: $(build.artifactstagingdirectory)\$(Build.DefinitionName)'
inputs:
SourceFolder: '$(Build.SourcesDirectory)'
Contents: '*.psd1'
TargetFolder: '$(build.artifactstagingdirectory)\$(Build.DefinitionName)'
OverWrite: true
- powershell: |
$BuildModuleFolder= '.buildmodules'
$null = New-Item -Name $BuildModuleFolder -Path $(Build.SourcesDirectory) -ItemType Directory
$PSModulePath = Join-Path -Path $(Build.SourcesDirectory) -ChildPath $BuildModuleFolder
Save-Module -Name Pester -Path $PSModulePath
Save-Module -Name PSScriptAnalyzer -Path $PSModulePath
Save-Module -Name InjectionHunter -Path $PSModulePath
workingDirectory: '$(build.artifactstagingdirectory)'
displayName: 'Get Pester, PSScriptAnalyser, InjectionHunter '
- powershell: |
$env:PSModulePath = '$(Build.SourcesDirectory)\.buildmodules' + ';' + $env:PSModulePath
Invoke-Pester -Script $(build.artifactstagingdirectory)\$(Build.DefinitionName)\* -OutputFile $(Common.TestResultsDirectory)\Test-Pester.XML -OutputFormat NUnitXML -EnableExit
workingDirectory: '$(build.artifactstagingdirectory)'
continueOnError: true
displayName: 'Run Pester'
- task: PublishTestResults@1
displayName: 'Publish Test Results'
inputs:
testRunner: NUnit
testResultsFiles: '$(Common.TestResultsDirectory)\Test-Pester.XML'
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: drop'
- powershell: |
git config user.email 'noreply@dev.azure.com'
git config user.name 'Azure DevOps'
"----"
git status --verbose
"----"
git add $(Build.DefinitionName).psd1
git commit -m "Updated version in psd1 ***NO_CI***"
"----"
git status --verbose
"----"
git push (('$(Build.Repository.Uri)').replace('https://', 'https://$(GitHubPat)@') + '.git') HEAD:$(Build.SourceBranchName) --verbose
"----"
workingDirectory: '$(Build.SourcesDirectory)'
displayName: 'Update PSD1 in Git'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
- powershell: 'Publish-Module -Path $(build.artifactstagingdirectory)\$(Build.DefinitionName) -NuGetAPIKey $(PowerShellGalleryNuGet)'
displayName: 'Publish to Gallery'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
- task: ArchiveFiles@2
displayName: 'Create Zip'
inputs:
rootFolderOrFile: '$(build.artifactstagingdirectory)\$(Build.DefinitionName)'
archiveFile: '$(Build.ArtifactStagingDirectory)\$(Build.DefinitionName)_$(Build.BuildNumber).zip'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
- task: ArchiveFiles@2
displayName: 'Create Tar'
inputs:
rootFolderOrFile: '$(build.artifactstagingdirectory)\$(Build.DefinitionName)'
archiveType: tar
archiveFile: '$(Build.ArtifactStagingDirectory)\$(Build.DefinitionName)_$(Build.BuildNumber).tar.gz'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
- task: GitHubRelease@0
displayName: 'GitHub release (create)'
inputs:
gitHubConnection: 'KJacobsen GitHub'
repositoryName: poshsecurity/Posh-SYSLOG
tagSource: manual
tag: '$(Build.BuildNumber)'
title: 'Version $(Build.BuildNumber)'
assets: |
$(Build.ArtifactStagingDirectory)/*.zip
$(Build.ArtifactStagingDirectory)/*.tar.gz
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))