# Try different methods to create Git repositories $GIT_SERVER = "git.alicorns.co.jp" $GIT_USER = "aitest" $GIT_PASSWORD = "Aitest123456" Write-Host "=== Attempting different methods to create Git repositories ===" -ForegroundColor Green Write-Host "" # Method 1: Try GitLab API (if the server is GitLab) Write-Host "Method 1: Check if GitLab server" -ForegroundColor Yellow try { $response = Invoke-WebRequest -Uri "https://$GIT_SERVER/api/v4/version" -UseBasicParsing -TimeoutSec 5 -ErrorAction Stop if ($response.StatusCode -eq 200) { Write-Host "[FOUND] This is a GitLab server" -ForegroundColor Green try { GitLab version: $($response.Content) } catch { Write-Host "GitLab detected" } } } catch { Write-Host "Not GitLab or not accessible" } Write-Host "" # Method 2: Try cURL to create directly Write-Host "Method 2: Try direct HTTP creation" -ForegroundColor Yellow foreach ($repo in @("office-file-handler", "dingtalk-media-sender")) { Write-Host "Creating $repo..." # 尝试使用git init --bare在服务器上 $authHeader = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("$GIT_USER`:$GIT_PASSWORD")) try { $headers = @{ "Authorization" = "Basic $authHeader" "Content-Type" = "application/json" } # 尝试不同的创建方法 $body = @{ name = $repo visibility = "private" } | ConvertTo-Json # 尝试GitLab风格 try { $response = Invoke-WebRequest -Uri "https://$GIT_SERVER/api/v4/projects" -Headers $headers -Method Post -Body $body -UseBasicParsing -ErrorAction Stop if ($response.StatusCode -in @(201, 200)) { Write-Host "[SUCCESS] $repo created via API" -ForegroundColor Green } } catch { Write-Host "[FAILED] API creation failed: $($_.Exception.Message)" -ForegroundColor Red } } catch { Write-Host "[ERROR] $repo creation failed: $($_.Exception.Message)" -ForegroundColor Red } } Write-Host "" Write-Host "=== Manual Creation Required ===" -ForegroundColor Yellow Write-Host "If automatic creation fails, you need to:" Write-Host "1. Login to https://$GIT_SERVER/ as $GIT_USER" Write-Host "2. Create repositories: office-file-handler, dingtalk-media-sender" Write-Host "3. Then run push commands"