Powershell 我将如何编写脚本来迭代bitBucket中的每个发布分支,并将它们分离到本地驱动器中各自的文件夹中?
我正在使用Powershell,到目前为止,我获得了创建一个名为“releases”的新目录的代码,但有点陷入了如何在特定文件夹中对各个版本进行分类的问题Powershell 我将如何编写脚本来迭代bitBucket中的每个发布分支,并将它们分离到本地驱动器中各自的文件夹中?,powershell,bitbucket,Powershell,Bitbucket,我正在使用Powershell,到目前为止,我获得了创建一个名为“releases”的新目录的代码,但有点陷入了如何在特定文件夹中对各个版本进行分类的问题 $DirectoryToCreate = '..\releases' if (-not (Test-Path -Path $DirectoryToCreate)) { try { New-Item -Path $DirectoryToCreate -ItemType Directory } catch { Write-E
$DirectoryToCreate = '..\releases'
if (-not (Test-Path -Path $DirectoryToCreate)) {
try {
New-Item -Path $DirectoryToCreate -ItemType
Directory
}
catch {
Write-Error -Message "Unable to create directory
'$DirectoryToCreate'. Error was: $_" -ErrorAction
Stop
}
}
# add list of branches into an array
$gitBranches = git branch -a
foreach ($branchPath in $gitBranches) {
# exclude copying master, blank, and non-releases
branches
if ($branchPath -notlike "*master*" -and
$branchPath -notlike "*blank*" -and $branchPath -like
"*remotes/origin/releases/*") {
$branch = Split-Path $branchPath -Leaf
$branch = "releases/" + $branch
#Write-Host("The branches are " + $branch)
git checkout $branch
$scripts = Get-ChildItem -Path '.\' -Name
foreach($script in $scripts) {
Write-Host("The files in the branch " +
$branch+ " are " + $script)
}
}
}