This commit is contained in:
2026-06-23 20:45:54 +09:30
parent 5f35ba4999
commit 810fbee944
+35 -35
View File
@@ -8,7 +8,6 @@ Write-Host "Unity CI Build - Target: $Target"
try { try {
# ----------------------------- # -----------------------------
# Load toolchain config # Load toolchain config
# ----------------------------- # -----------------------------
@@ -23,6 +22,17 @@ try {
throw "Unity Hub not found at: $hubExe" throw "Unity Hub not found at: $hubExe"
} }
# -----------------------------
# CI SAFETY: kill stale licensing / unity processes
# -----------------------------
Write-Host "Cleaning up stale Unity/Licensing processes..."
Get-Process Unity* -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue
Get-Process LicensingClient* -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue
Get-Process Unity.Licensing* -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue
Start-Sleep -Seconds 2
# ----------------------------- # -----------------------------
# Ensure Unity is installed # Ensure Unity is installed
# ----------------------------- # -----------------------------
@@ -55,7 +65,6 @@ try {
Write-Host "Checking Unity modules..." Write-Host "Checking Unity modules..."
# Query installed editors/modules once
$installedEditors = & $hubExe -- --headless editors --installed $installedEditors = & $hubExe -- --headless editors --installed
foreach ($module in $modules) { foreach ($module in $modules) {
@@ -91,16 +100,15 @@ try {
Write-Host "Build Method: $method" Write-Host "Build Method: $method"
# ----------------------------- # -----------------------------
# Paths # Paths (ALL LOGS INTO BUILDS FOLDER)
# ----------------------------- # -----------------------------
$logFile = Join-Path $PWD "unity_build.log"
$artifactDir = Join-Path $PWD "Builds" $artifactDir = Join-Path $PWD "Builds"
$artifactLog = Join-Path $artifactDir "unity_build.log"
New-Item -ItemType Directory -Force -Path $artifactDir | Out-Null New-Item -ItemType Directory -Force -Path $artifactDir | Out-Null
# Remove previous log $logFile = Join-Path $artifactDir "unity_build.log"
$artifactLog = Join-Path $artifactDir "unity_build_last_run.log"
# Clean old log
if (Test-Path $logFile) { if (Test-Path $logFile) {
Remove-Item $logFile -Force Remove-Item $logFile -Force
} }
@@ -133,7 +141,7 @@ try {
# ----------------------------- # -----------------------------
# Wait for log file creation # Wait for log file creation
# ----------------------------- # -----------------------------
$timeoutSeconds = 30 $timeoutSeconds = 60
$elapsed = 0 $elapsed = 0
while (!(Test-Path $logFile) -and $elapsed -lt $timeoutSeconds) { while (!(Test-Path $logFile) -and $elapsed -lt $timeoutSeconds) {
@@ -142,7 +150,7 @@ try {
} }
if (!(Test-Path $logFile)) { if (!(Test-Path $logFile)) {
throw "Unity log file was not created." throw "Unity log file was not created at: $logFile"
} }
# ----------------------------- # -----------------------------
@@ -178,10 +186,8 @@ try {
Write-Host "Exit Code: $($process.ExitCode)" Write-Host "Exit Code: $($process.ExitCode)"
Write-Host "" Write-Host ""
if (Test-Path $logFile) { Write-Host "===== Last 500 Log Lines ====="
Write-Host "===== Last 500 Log Lines =====" Get-Content $logFile -Tail 500
Get-Content $logFile -Tail 500
}
exit $process.ExitCode exit $process.ExitCode
} }
@@ -192,27 +198,22 @@ try {
Write-Host "" Write-Host ""
Write-Host "===== Build Summary =====" Write-Host "===== Build Summary ====="
if (Test-Path $logFile) { Get-Content $logFile |
Select-String `
Get-Content $logFile | -Pattern @(
Select-String ` "Build completed",
-Pattern @( "Build succeeded",
"Build completed" "Build finished",
"Build succeeded" "Total time"
"Build finished" ) |
"Total time" ForEach-Object {
) ` Write-Host $_.Line
-SimpleMatch |
ForEach-Object {
Write-Host $_.Line
}
Write-Host ""
Write-Host "===== Last 50 Log Lines ====="
Get-Content $logFile -Tail 50
} }
Write-Host ""
Write-Host "===== Last 50 Log Lines ====="
Get-Content $logFile -Tail 50
Write-Host "" Write-Host ""
Write-Host "SUCCESS: $Target" Write-Host "SUCCESS: $Target"
@@ -223,5 +224,4 @@ catch {
} }
finally { finally {
Write-Host "Cleanup complete." Write-Host "Cleanup complete."
# Stop-Process -Name "Unity","Unity Hub" -Force -ErrorAction SilentlyContinue }
}