# 定義基礎URL和數據庫列表
$BASE_URL = "http://8.8.11.99:8999/yaya/"
$DATABASES = "common-service", "bi-system", "erp", "gateway", "pdm", "plm", "public-service", "scm", "ums", "wms"
# 遍歷數據庫列表
foreach ($prj in $DATABASES) {
# 構建倉庫URL和本地路徑
$RepoURL = $BASE_URL + $prj + ".git"
$LocalRepoPath = ".\$prj"
$Dbranch = "test"
# 檢查本地目錄是否存在,如果不存在則克隆倉庫
if (!(Test-Path -Path $LocalRepoPath)) {
Write-Host "Cloning $RepoURL to $LocalRepoPath ..."
git clone $RepoURL $LocalRepoPath
if ($LASTEXITCODE -ne 0) {
Write-Host "Failed to clone $RepoURL"
} else {
# 切換到特定分支并拉取更新(如果需要)
cd $LocalRepoPath
git checkout $Dbranch
git pull
}
cd .. # 返回到上級目錄
} else {
Write-Host "Repository $RepoURL already exists locally at $LocalRepoPath"
}
}
# 暫停以查看輸出(如果需要)
# Read-Host -Prompt "Press Enter to continue..."
# 腳本結束,不需要顯式退出,因為PowerShell會在執行完畢后自動退出