-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yml
61 lines (50 loc) · 2.01 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
# 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:
- master
pool:
vmImage: 'windows-latest'
steps:
- task: CmdLine@2
name: "RepoClone"
displayName: "Clone Get-Duplicate-Files repo to local storage"
inputs:
script: |
dir $(Agent.BuildDirectory)
# Create directory with two duplicate files
- task: PowerShell@2
name: "CreateDummyDuplicates"
displayName: "Create duplicate files"
inputs:
targetType: 'inline'
script: |
New-Item -Path "C:\" -Name "Test" -ItemType Directory
$counter = 0
while ($counter -lt 100) {
New-Item -Path "C:\Test" -Name "Test$counter.txt" -ItemType File -Value "HelloWorld"
$counter ++
}
Write-Host "99 duplicate files created for testing purposes."
- task: CmdLine@2
name: "RunMonitorPS1"
displayName: "Run monitor.ps1"
inputs:
script: 'powershell.exe ".\monitor.ps1 -SEARCH_LOCATION C:\Test -LOG_LOCATION C:\Test -MONITORING_FREQUENCY 1"'
workingDirectory: '$(Build.Repository.LocalPath)'
- task: PowerShell@2
name: "DuplicateFileCheck"
displayName: "Check duplicate files"
inputs:
targetType: 'inline'
script: |
$Report = Get-ChildItem -Path C:\Test -Recurse | where {$_.Name -like "*html"}
$Regex = Get-Content -Path $Report.FullName | Select-String '</h1><h2>([0-9]+) possible duplicates found</h2><h3>' -AllMatches
$PossibleDuplicatesFound = $Regex.Matches[0].Groups[1].Value
If ($PossibleDuplicatesFound -ne 99) {
Write-Host "##vso[task.logissue type=error;sourcepath=DuplicateFileLocator\DuplicateFileLocator.psm1;linenumber=226;columnnumber=1;code=100;]Incorrect number of duplicate files detected. 99 duplicate files were created, but $PossibleDuplicatesFound duplicate files were detected."
exit 1
} else {
Write-Host "$PossibleDuplicatesFound/99 duplicate files detected."
}