more
This commit is contained in:
+35
-35
@@ -8,7 +8,6 @@ Write-Host "Unity CI Build - Target: $Target"
|
||||
|
||||
try {
|
||||
|
||||
|
||||
# -----------------------------
|
||||
# Load toolchain config
|
||||
# -----------------------------
|
||||
@@ -23,6 +22,17 @@ try {
|
||||
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
|
||||
# -----------------------------
|
||||
@@ -55,7 +65,6 @@ try {
|
||||
|
||||
Write-Host "Checking Unity modules..."
|
||||
|
||||
# Query installed editors/modules once
|
||||
$installedEditors = & $hubExe -- --headless editors --installed
|
||||
|
||||
foreach ($module in $modules) {
|
||||
@@ -91,16 +100,15 @@ try {
|
||||
Write-Host "Build Method: $method"
|
||||
|
||||
# -----------------------------
|
||||
# Paths
|
||||
# Paths (ALL LOGS INTO BUILDS FOLDER)
|
||||
# -----------------------------
|
||||
$logFile = Join-Path $PWD "unity_build.log"
|
||||
|
||||
$artifactDir = Join-Path $PWD "Builds"
|
||||
$artifactLog = Join-Path $artifactDir "unity_build.log"
|
||||
|
||||
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) {
|
||||
Remove-Item $logFile -Force
|
||||
}
|
||||
@@ -133,7 +141,7 @@ try {
|
||||
# -----------------------------
|
||||
# Wait for log file creation
|
||||
# -----------------------------
|
||||
$timeoutSeconds = 30
|
||||
$timeoutSeconds = 60
|
||||
$elapsed = 0
|
||||
|
||||
while (!(Test-Path $logFile) -and $elapsed -lt $timeoutSeconds) {
|
||||
@@ -142,7 +150,7 @@ try {
|
||||
}
|
||||
|
||||
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 ""
|
||||
|
||||
if (Test-Path $logFile) {
|
||||
Write-Host "===== Last 500 Log Lines ====="
|
||||
Get-Content $logFile -Tail 500
|
||||
}
|
||||
Write-Host "===== Last 500 Log Lines ====="
|
||||
Get-Content $logFile -Tail 500
|
||||
|
||||
exit $process.ExitCode
|
||||
}
|
||||
@@ -192,27 +198,22 @@ try {
|
||||
Write-Host ""
|
||||
Write-Host "===== Build Summary ====="
|
||||
|
||||
if (Test-Path $logFile) {
|
||||
|
||||
Get-Content $logFile |
|
||||
Select-String `
|
||||
-Pattern @(
|
||||
"Build completed"
|
||||
"Build succeeded"
|
||||
"Build finished"
|
||||
"Total time"
|
||||
) `
|
||||
-SimpleMatch |
|
||||
ForEach-Object {
|
||||
Write-Host $_.Line
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "===== Last 50 Log Lines ====="
|
||||
|
||||
Get-Content $logFile -Tail 50
|
||||
Get-Content $logFile |
|
||||
Select-String `
|
||||
-Pattern @(
|
||||
"Build completed",
|
||||
"Build succeeded",
|
||||
"Build finished",
|
||||
"Total time"
|
||||
) |
|
||||
ForEach-Object {
|
||||
Write-Host $_.Line
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "===== Last 50 Log Lines ====="
|
||||
Get-Content $logFile -Tail 50
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "SUCCESS: $Target"
|
||||
|
||||
@@ -223,5 +224,4 @@ catch {
|
||||
}
|
||||
finally {
|
||||
Write-Host "Cleanup complete."
|
||||
# Stop-Process -Name "Unity","Unity Hub" -Force -ErrorAction SilentlyContinue
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user