Skip to content
This repository was archived by the owner on Dec 8, 2021. It is now read-only.

Commit 8433f21

Browse files
authored
Move PSThreadJob module to this repo, and rename to Microsoft.PowerShell.ThreadJob (#74)
1 parent a82fd29 commit 8433f21

18 files changed

+3079
-0
lines changed
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
name: $(BuildDefinitionName)-$(date:yyMM).$(date:dd)$(rev:rrr)
2+
trigger:
3+
# Batch merge builds together while a merge build is running
4+
batch: true
5+
branches:
6+
include:
7+
- master
8+
pr:
9+
branches:
10+
include:
11+
- master
12+
13+
stages:
14+
- stage: Build
15+
displayName: Build PowerShell Package
16+
jobs:
17+
- job: BuildPkg
18+
displayName: Build Package
19+
pool:
20+
name: Package ES CodeHub Lab E
21+
steps:
22+
- powershell: |
23+
$powerShellPath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'powershell'
24+
Invoke-WebRequest -Uri https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/install-powershell.ps1 -outfile ./install-powershell.ps1
25+
./install-powershell.ps1 -Destination $powerShellPath
26+
$vstsCommandString = "vso[task.setvariable variable=PATH]$powerShellPath;$env:PATH"
27+
Write-Host "sending " + $vstsCommandString
28+
Write-Host "##$vstsCommandString"
29+
displayName: Install PowerShell Core
30+
31+
- task: UseDotNet@2
32+
displayName: 'Install .NET Core 3.1.100 sdk'
33+
inputs:
34+
packageType: sdk
35+
version: 3.1.100
36+
37+
- task: PkgESSetupBuild@10
38+
displayName: 'Package ES - Setup Build'
39+
inputs:
40+
productName: PSRemotingTools
41+
useDfs: false
42+
43+
- pwsh: |
44+
Get-ChildItem -Path env:
45+
displayName: Capture environment for build
46+
condition: succeededOrFailed()
47+
48+
- pwsh: |
49+
dir $env:USERPROFILE\Documents\PowerShell\Modules\* -Directory -ErrorAction SilentlyContinue | Remove-Item -Recurse -Force -Verbose -ErrorAction SilentlyContinue
50+
displayName: Clean PowerShell modules directory
51+
52+
- pwsh: |
53+
Get-Module -Name PowerShellGet -ListAvailable
54+
Import-Module -Name PowerShellGet
55+
displayName: Import PowerShellGet Module
56+
57+
- pwsh: |
58+
Install-Module -Name "platyPS","Pester" -Force
59+
displayName: Install dependencies
60+
- pwsh: |
61+
Install-Module -Name "PSScriptAnalyzer" -RequiredVersion 1.18.0 -Force
62+
displayName: Install PSScriptAnalyzer
63+
- pwsh: |
64+
Install-Module -Name PSPackageProject -Force
65+
displayName: Install PSPackageProject module
66+
- pwsh: |
67+
$(Build.SourcesDirectory)/build.ps1 -Build -BuildConfiguration Release
68+
displayName: Build and publish artifact
69+
70+
- pwsh: |
71+
Install-Module -Name PSPackageProject -Force
72+
$config = Get-PSPackageProjectConfiguration
73+
$signSrcPath = "$($config.BuildOutputPath)\$($config.ModuleName)"
74+
$signOutPath = "$($config.BuildOutputPath)\$($config.ModuleName)\Signed"
75+
if (! (Test-Path -Path $signOutPath)) {
76+
$null = New-Item -Path $signOutPath -ItemType Directory
77+
}
78+
$signXmlPath = "$($config.SourcePath)\..\sign-module-files.xml"
79+
# Set signing src path variable
80+
$vstsCommandString = "vso[task.setvariable variable=signSrcPath]${signSrcPath}"
81+
Write-Host "sending " + $vstsCommandString
82+
Write-Host "##$vstsCommandString"
83+
# Set signing out path variable
84+
$vstsCommandString = "vso[task.setvariable variable=signOutPath]${signOutPath}"
85+
Write-Host "sending " + $vstsCommandString
86+
Write-Host "##$vstsCommandString"
87+
# Set signing xml path
88+
$vstsCommandString = "vso[task.setvariable variable=signXmlPath]${signXmlPath}"
89+
Write-Host "sending " + $vstsCommandString
90+
Write-Host "##$vstsCommandString"
91+
displayName: Set up for code signing
92+
93+
- pwsh: |
94+
Get-ChildItem -Path env:
95+
displayName: Capture environment for code signing
96+
condition: succeededOrFailed()
97+
98+
- task: PkgESCodeSign@10
99+
displayName: Sign build files
100+
env:
101+
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
102+
inputs:
103+
signConfigXml: '$(signXmlPath)'
104+
inPathRoot: '$(signSrcPath)'
105+
outPathRoot: '$(signOutPath)'
106+
binVersion: Production
107+
binVersionOverride: ''
108+
condition: and(and(succeeded(), eq(variables['Build.Reason'], 'Manual')), ne(variables['SkipSigning'], 'True'))
109+
110+
- stage: Compliance
111+
displayName: Compliance
112+
dependsOn: Build
113+
jobs:
114+
- job: ComplianceJob
115+
pool:
116+
name: Package ES CodeHub Lab E
117+
steps:
118+
- template: compliance.yml
119+
120+
- stage: Test
121+
displayName: Test Package
122+
dependsOn: Build
123+
jobs:
124+
- template: test.yml
125+
parameters:
126+
jobName: TestPkgWin
127+
displayName: PowerShell Core on Windows
128+
imageName: windows-2019
129+
130+
# - template: test.yml
131+
# parameters:
132+
# jobName: TestPkgWinPS
133+
# displayName: Windows PowerShell on Windows
134+
# imageName: windows-2019
135+
# powershellExecutable: powershell
136+
137+
- template: test.yml
138+
parameters:
139+
jobName: TestPkgUbuntu16
140+
displayName: PowerShell Core on Ubuntu 16.04
141+
imageName: ubuntu-16.04
142+
143+
- template: test.yml
144+
parameters:
145+
jobName: TestPkgWinMacOS
146+
displayName: PowerShell Core on macOS
147+
imageName: macOS-10.14
148+
149+
- stage: Release
150+
displayName: Release Package
151+
condition: and(and(succeeded(), eq(variables['Build.Reason'], 'Manual')), eq(variables['Publish'], 'True'))
152+
jobs:
153+
- template: release.yml
154+
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
steps:
2+
3+
- powershell: |
4+
$powerShellPath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'powershell'
5+
Invoke-WebRequest -Uri https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/install-powershell.ps1 -outfile ./install-powershell.ps1
6+
./install-powershell.ps1 -Destination $powerShellPath
7+
$vstsCommandString = "vso[task.setvariable variable=PATH]$powerShellPath;$env:PATH"
8+
Write-Host "sending " + $vstsCommandString
9+
Write-Host "##$vstsCommandString"
10+
displayName: Install PowerShell Core
11+
12+
- pwsh: |
13+
Install-Module -Name "platyPS","Pester" -Force
14+
displayName: Install platyPS
15+
16+
- pwsh: |
17+
Install-Module -Name "PSScriptAnalyzer" -RequiredVersion 1.18.0 -Force
18+
displayName: Install PSScripAnalyzer
19+
20+
- pwsh: |
21+
Install-Module -Name PSPackageProject -Force
22+
displayName: Install PSPackageProject module
23+
24+
- task: DownloadBuildArtifacts@0
25+
displayName: 'Download artifacts'
26+
inputs:
27+
buildType: current
28+
downloadType: specifc
29+
itemPattern: '**/*.nupkg'
30+
downloadPath: '$(System.ArtifactsDirectory)'
31+
32+
- pwsh: |
33+
$sourceName = 'pspackageproject-local-repo'
34+
Register-PSRepository -Name $sourceName -SourceLocation '$(System.ArtifactsDirectory)' -ErrorAction Ignore
35+
$config = Get-PSPackageProjectConfiguration
36+
$buildOutputPath = $config.BuildOutputPath
37+
$null = New-Item -ItemType Directory -Path $buildOutputPath -Verbose
38+
$moduleName = $config.ModuleName
39+
Save-Module -Repository $sourceName -Name $moduleName -Path $config.BuildOutputPath
40+
$vstsCommandString = "vso[task.setvariable variable=BUILD_SOURCE]$($config.BuildOutputPath)"
41+
Write-Host "sending " + $vstsCommandString
42+
Write-Host "##$vstsCommandString"
43+
displayName: Extract product artifact
44+
45+
- pwsh: |
46+
$config = Get-PSPackageProjectConfiguration
47+
dir "$($config.BuildOutputPath)/*" -r 2>$null
48+
displayName: 'BuildOutputPath directory'
49+
50+
- task: securedevelopmentteam.vss-secure-development-tools.build-task-antimalware.AntiMalware@3
51+
displayName: 'Run Defender Scan'
52+
53+
- task: securedevelopmentteam.vss-secure-development-tools.build-task-credscan.CredScan@2
54+
displayName: 'Run CredScan'
55+
inputs:
56+
toolMajorVersion: V2
57+
debugMode: false
58+
continueOnError: true
59+
60+
- task: securedevelopmentteam.vss-secure-development-tools.build-task-binskim.BinSkim@3
61+
displayName: 'Run BinSkim '
62+
inputs:
63+
InputType: Basic
64+
AnalyzeTarget: '$(BUILD_SOURCE)\Microsoft.PowerShell.SecretManagement\Microsoft.PowerShell.SecretManagement.dll'
65+
AnalyzeSymPath: 'SRV*'
66+
AnalyzeVerbose: true
67+
AnalyzeHashes: true
68+
AnalyzeStatistics: true
69+
continueOnError: true
70+
71+
- task: securedevelopmentteam.vss-secure-development-tools.build-task-policheck.PoliCheck@1
72+
displayName: 'Run PoliCheck'
73+
inputs:
74+
targetType: F
75+
optionsFC: 0
76+
optionsXS: 0
77+
optionsPE: '1|2|3|4'
78+
optionsHMENABLE: 0
79+
# optionsRulesDBPath: '$(Build.SourcesDirectory)\tools\terms\PowerShell-Terms-Rules.mdb'
80+
# optionsFTPATH: '$(Build.SourcesDirectory)\tools\terms\FileTypeSet.xml'
81+
toolVersion: 5.8.2.1
82+
continueOnError: true
83+
84+
- task: securedevelopmentteam.vss-secure-development-tools.build-task-publishsecurityanalysislogs.PublishSecurityAnalysisLogs@2
85+
displayName: 'Publish Security Analysis Logs to Build Artifacts'
86+
continueOnError: true
87+
88+
- task: securedevelopmentteam.vss-secure-development-tools.build-task-uploadtotsa.TSAUpload@1
89+
displayName: 'TSA upload to Codebase: PSThreadJob_201912 Stamp: Azure'
90+
inputs:
91+
codeBaseName: PSThreadJob_201912
92+
tsaVersion: TsaV2
93+
uploadFortifySCA: false
94+
uploadFxCop: false
95+
uploadModernCop: false
96+
uploadPREfast: false
97+
uploadRoslyn: false
98+
uploadTSLint: false
99+
uploadAPIScan: false
100+
101+
- task: securedevelopmentteam.vss-secure-development-tools.build-task-report.SdtReport@1
102+
displayName: 'Create Security Analysis Report'
103+
inputs:
104+
TsvFile: false
105+
APIScan: false
106+
BinSkim: false
107+
CredScan: true
108+
PoliCheck: true
109+
PoliCheckBreakOn: Severity2Above
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
parameters:
2+
jobName: release
3+
imageName: windows-2019
4+
displayName: Release
5+
6+
jobs:
7+
- job: ${{ parameters.jobName }}
8+
pool:
9+
vmImage: ${{ parameters.imageName }}
10+
displayName: ${{ parameters.displayName }}
11+
steps:
12+
- task: DownloadBuildArtifacts@0
13+
displayName: 'Download artifacts'
14+
inputs:
15+
buildType: current
16+
downloadType: single
17+
artifactName: NuPkg
18+
downloadPath: '$(System.ArtifactsDirectory)'
19+
- task: NuGetToolInstaller@1
20+
displayName: 'Install NuGet'
21+
- pwsh: |
22+
nuget push $(System.ArtifactsDirectory)\nupkg\*.nupkg -ApiKey $(NuGetApiKey) -Source https://www.powershellgallery.com/api/v2/package/ -NonInteractive
23+
displayName: Publish Package
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
parameters:
2+
jobName: TestPkgWin
3+
imageName: windows-2019
4+
displayName: PowerShell Core on Windows
5+
powershellExecutable: pwsh
6+
7+
jobs:
8+
- job: ${{ parameters.jobName }}
9+
pool:
10+
vmImage: ${{ parameters.imageName }}
11+
displayName: ${{ parameters.displayName }}
12+
steps:
13+
- ${{ parameters.powershellExecutable }}: |
14+
Install-Module -Name "platyPS","Pester" -Force
15+
displayName: Install dependencies
16+
17+
- ${{ parameters.powershellExecutable }}: |
18+
Install-Module -Name "PSScriptAnalyzer" -RequiredVersion 1.18.0 -Force
19+
displayName: Install dependencies
20+
21+
- ${{ parameters.powershellExecutable }}: |
22+
Install-Module -Name PSPackageProject -Force
23+
displayName: Install PSPackageProject module
24+
25+
- task: DownloadBuildArtifacts@0
26+
displayName: 'Download artifacts'
27+
inputs:
28+
buildType: current
29+
downloadType: specific
30+
itemPattern: '**/*.nupkg'
31+
downloadPath: '$(System.ArtifactsDirectory)'
32+
33+
- ${{ parameters.powershellExecutable }}: |
34+
$sourceName = 'pspackageproject-local-repo'
35+
Register-PSRepository -Name $sourceName -SourceLocation '$(System.ArtifactsDirectory)' -ErrorAction Ignore
36+
$config = Get-PSPackageProjectConfiguration
37+
$buildOutputPath = $config.BuildOutputPath
38+
$null = New-Item -ItemType Directory -Path $buildOutputPath -Verbose
39+
$moduleName = $config.ModuleName
40+
Save-Module -Repository $sourceName -Name $moduleName -Path $config.BuildOutputPath
41+
displayName: Extract product artifact
42+
43+
- ${{ parameters.powershellExecutable }}: |
44+
Invoke-PSPackageProjectTest -Type Functional
45+
displayName: Execute functional tests
46+
errorActionPreference: continue
47+
48+
- ${{ parameters.powershellExecutable }}: |
49+
Invoke-PSPackageProjectTest -Type StaticAnalysis
50+
displayName: Execute static analysis tests
51+
errorActionPreference: continue
52+
condition: succeededOrFailed()
53+
54+
- ${{ parameters.powershellExecutable }}: |
55+
Unregister-PSRepository -Name 'pspackageproject-local-repo' -ErrorAction Ignore
56+
displayName: Unregister temporary PSRepository
57+
condition: always()

0 commit comments

Comments
 (0)