Why wont the $branch and $FileDirectory parameter work in Process-DropDownlist function? It is not replaced when I try to look at the string when I print it to console.
It will just come out as $fileDirectory and $branch. Please advice........
function Process-DropDownList() {
[CmdletBinding()]
Param(
[Parameter(Mandatory = $True, ValueFromPipeline = $True)]
[string] $Branch,
[Parameter(Mandatory = $True)]
[string] $FileDirectory,
[Parameter(Mandatory = $False)]
[string] $Uri
)
Begin {
$outFileDirectories = @(
@{ Pattern = 'fibp*'; Directory = '$FileDirectory\1\$Branch\swagger.json' },
@{ Pattern = 'fibf*'; Directory = '$FileDirectory\2\$Branch\swagger.json' },
@{ Pattern = 'fifi*'; Directory = '$FileDirectory\3\$Branch\swagger.json' },
@{ Pattern = 'fibh*'; Directory = '$FileDirectory\4\$Branch\swagger.json' },
@{ Pattern = 'fiuc*'; Directory = '$FileDirectory\5\$Branch\swagger.json' },
@{ Pattern = 'fibu*'; Directory = '$FileDirectory\6\$Branch\swagger.json' },
@{ Pattern = 'fibc*'; Directory = '$FileDirectory\7\$Branch\swagger.json' }
)
$outDropLists = @(
@{ Pattern = 'fibp*'; DropName = 'Someting1 - $Branch' },
@{ Pattern = 'fibf*'; DropName = 'Something2 - $Branch' },
@{ Pattern = 'fifi*'; DropName = 'Someting3 - $Branch' },
@{ Pattern = 'fibh*'; DropName = 'Someting4 - $Branch' },
@{ Pattern = 'fiuc*'; DropName = 'Someting5 - $Branch' },
@{ Pattern = 'fibu*'; DropName = 'Something6 - $Branch' },
@{ Pattern = 'fibc*'; DropName = 'Something7 - $Branch' }
)
}
Process {
$outFileDirectory = $outFileDirectories |
Where-Object -FilterScript { $Branch -Like $_.Pattern} |
Select-Object -First 1 |
ForEach-Object -Process { $_.Directory }
$outDropList = $outDropLists |
Where-Object -FilterScript { $Branch -Like $_.Pattern} |
Select-Object -First 1 |
ForEach-Object -Process { $_.DropName }
$outFileDirectory
$outDropList
}
}
$data = Git ls-remote --refs ssh://git@stometing:7669/containers.git
$reg = '(fi[-\w]+)\s*$'
$branches = $data | Select-String $reg -AllMatches | ForEach-Object { $_.Matches.Value }
$branches | Process-DropDownList -FileDirectory http://something/swagger