-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathazure-pipelines.yml
126 lines (103 loc) · 3.46 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
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml
trigger:
- main
pool:
name: LinuxBuild2
steps:
- checkout: self
clean: true
fetchTags: false
- task: Bash@3
displayName: 'apt update'
continueOnError: True
inputs:
targetType: inline
script: >-
sudo apt-get update
failOnStderr: false
- task: Bash@3
displayName: 'Install ansible galaxy and deps if not installed'
inputs:
targetType: inline
script: >-
sudo apt-get install python3-pip git libffi-dev libssl-dev -y
sudo apt-get install ansible -y
failOnStderr: true
- task: CopyFiles@2
inputs:
SourceFolder: '$(Build.SourcesDirectory)'
Contents: '**/**'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
CleanTargetFolder: true
OverWrite: true
- task: Bash@3
displayName: 'Quality Gate with PSSCript Analyzer for Errors '
continueOnError: False
inputs:
targetType: inline
workingDirectory: '$(Build.ArtifactStagingDirectory)'
script: >-
pwsh -Command "Install-Module -Name PSScriptAnalyzer -Force"
pwsh -Command "Import-Module -Name PSScriptAnalyzer"
pwsh -Command "Invoke-ScriptAnalyzer -Path ./plugins/modules/ -Profile ./playbooks/files/PSAnalyzerProfileError.txt -Recurse"
failOnStderr: true
- task: Bash@3
displayName: 'Analyze with PSSCript Analyzer'
continueOnError: True
inputs:
targetType: inline
workingDirectory: '$(Build.ArtifactStagingDirectory)'
script: >-
pwsh -Command "Install-Module -Name PSScriptAnalyzer -Force"
pwsh -Command "Import-Module -Name PSScriptAnalyzer"
pwsh -Command "Invoke-ScriptAnalyzer ./plugins/modules/ | Select-Object Severity, Line, Message, RuleName | Format-List"
failOnStderr: true
- task: Bash@3
displayName: 'Analyze with Injection Hunter'
continueOnError: True
inputs:
targetType: inline
workingDirectory: '$(Build.ArtifactStagingDirectory)'
script: >-
pwsh -Command "Install-Module -Name InjectionHunter -Force"
pwsh -Command "Import-Module -Name InjectionHunter"
pwsh -Command "Invoke-ScriptAnalyzer ./plugins/modules/ -CustomRulePath (Get-Module InjectionHunter -List | % Path) -v | Format-List"
failOnStderr: true
- task: Bash@3
displayName: 'Build ansible galaxy collection'
inputs:
targetType: inline
workingDirectory: '$(Build.ArtifactStagingDirectory)'
script: >-
ansible-galaxy collection build
- task: CopyFiles@2
inputs:
SourceFolder: '$(Build.ArtifactStagingDirectory)'
Contents: '*.tar.gz'
TargetFolder: '$(Build.BinariesDirectory)'
CleanTargetFolder: true
OverWrite: true
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.BinariesDirectory)'
ArtifactName: 'xray700r-hyperv'
publishLocation: 'Container'
failOnStderr: true
- task: Bash@3
displayName: 'Publish to ansible galaxy namespace'
continueOnError: True
inputs:
targetType: inline
workingDirectory: '$(Build.BinariesDirectory)'
script: >-
tarfile=$(find . -type f -name 'xray700r-hyperv-*.tar.gz' -exec basename {} ';')
ansible-galaxy collection publish ./$tarfile --api-key $(GalaxyApiKeyHyperv)
failOnStderr: false
- task: DeleteFiles@1
inputs:
SourceFolder: '$(Build.ArtifactStagingDirectory)'
Contents: '**/**'
RemoveDotFiles: true