-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathset-artifact-packages.yml
More file actions
51 lines (43 loc) · 3.04 KB
/
set-artifact-packages.yml
File metadata and controls
51 lines (43 loc) · 3.04 KB
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
parameters:
PackageInfo: ''
Artifacts: []
steps:
# Package-Properties folder contains the package properties for all discovered packages that were either A) affected by the PR or
# B) explicitly present in the service directory. This repo splits the builds into two categories: "mgmt" and "dataplane". While
# a given directory may contain both, there will be a separate build definition to release the management packages. Due to this
# we need to artificially filter the packages to ensure that only the packages targeted for THAT ci.yml are built.
# When we merge the PR adding js - pullrequest, this code will also merge, meaning the public - <service> - ci builds will still operate
# EXACTLY the same as they did before the pipelinev3 change. This is important to ensure that we don't accidentally build the wrong packages
# while in the integration period. After we disable all the public `js - <service> - ci` builds, only the `js - pullrequest` build WONT provide
# an artifact list, which will allow the expand/contract. Meanwhile the internal builds will continue to provide the artifact list from their
# individual ci.yml and ci.mgmt.yml files.
- pwsh: |
$artifacts = '${{ convertToJson(parameters.Artifacts) }}' | ConvertFrom-Json
$knownArtifacts = @()
if ($artifacts) {
$knownArtifacts = $artifacts | ForEach-Object { $_.name }
}
$packageProperties = Get-ChildItem -Recurse "${{ parameters.PackageInfo }}" *.json `
| Where-Object { if($knownArtifacts) { $knownArtifacts -contains $_.Name.Replace(".json", "") } else { $true } }
$pkgNames = $packageProperties | ForEach-Object { $_.Name.Replace(".json", "") }
$setting = $pkgNames -join ","
Write-Host "Setting ArtifactPackageNames to: `n$setting"
Write-Host "##vso[task.setvariable variable=ArtifactPackageNames;]$setting"
displayName: Resolve Targeted Packages
condition: eq(variables['ArtifactPackageNames'], '')
- pwsh: |
# set changed services given the set of changed packages, this will mean that
# ChangedServices will be appropriate for the batched set of packages if that is indeed how
# we set the targeted artifacts
$packageProperties = Get-ChildItem -Recurse "${{ parameters.PackageInfo }}" *.json `
| Foreach-Object { Get-Content -Raw -Path $_.FullName | ConvertFrom-Json }
$packageSet = "$(ArtifactPackageNames)" -split ","
$changedServicesArray = $packageProperties | Where-Object { $packageSet -contains $_.ArtifactName }
| ForEach-Object { $_.ServiceDirectory } | Get-Unique
$changedServices = $changedServicesArray -join " "
$commaChangedServices = $changedServicesArray -join ","
Write-Host "##vso[task.setvariable variable=ChangedServices;]$changedServices"
Write-Host "##vso[task.setvariable variable=ChangedServicesCsv;]$commaChangedServices"
Write-Host "This run is targeting: `n$(ArtifactPackageNames) in [$changedServices]"
displayName: Resolve Targeted Packages
condition: ne(variables['ArtifactPackageNames'], '')