Token from protected file (fixes CI var resolution)
This commit is contained in:
+6
-9
@@ -1,4 +1,5 @@
|
||||
# Spiegelt dieses Repo nach Gitea (echte Branches/Tags) bei jedem Push.
|
||||
# Gitea-Push-Token liegt geschuetzt in C:\agent-secrets\gitea_push_token.txt (nur Agent-Dienst lesbar).
|
||||
trigger:
|
||||
branches:
|
||||
include:
|
||||
@@ -10,6 +11,7 @@ pool:
|
||||
variables:
|
||||
GITEA_HOST: 'git.wvds.it'
|
||||
GITEA_ORG: 'wvds-public'
|
||||
TOKEN_FILE: 'C:\agent-secrets\gitea_push_token.txt'
|
||||
|
||||
steps:
|
||||
- checkout: none
|
||||
@@ -18,15 +20,11 @@ steps:
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$repoName = "$(Build.Repository.Name)"
|
||||
$devopsUrl = "$(Build.Repository.Uri)"
|
||||
$tok = $env:GITEA_TOKEN
|
||||
|
||||
# Diagnose: kommt der Token an? (nur Laenge + Rand, nicht der Wert)
|
||||
if ([string]::IsNullOrEmpty($tok)) {
|
||||
Write-Host "##[error]GITEA_TOKEN ist LEER - Secret-Variable nicht gesetzt!"
|
||||
exit 1
|
||||
}
|
||||
$tlen = $tok.Length
|
||||
Write-Host "GITEA_TOKEN empfangen: Laenge=$tlen, Start=$($tok.Substring(0,[Math]::Min(4,$tlen)))"
|
||||
if (-not (Test-Path "$(TOKEN_FILE)")) { Write-Error "Token-Datei fehlt: $(TOKEN_FILE)"; exit 1 }
|
||||
$tok = (Get-Content "$(TOKEN_FILE)" -Raw).Trim()
|
||||
if ([string]::IsNullOrEmpty($tok)) { Write-Error "Token leer"; exit 1 }
|
||||
Write-Host "Gitea-Token geladen (Laenge $($tok.Length))"
|
||||
|
||||
$work = Join-Path "$(Agent.TempDirectory)" "mirror-src"
|
||||
if (Test-Path $work) { Remove-Item -LiteralPath $work -Recurse -Force }
|
||||
@@ -44,5 +42,4 @@ steps:
|
||||
Write-Host "Spiegelung erfolgreich."
|
||||
displayName: 'Mirror to Gitea'
|
||||
env:
|
||||
GITEA_TOKEN: $(GITEA_TOKEN)
|
||||
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
|
||||
|
||||
Reference in New Issue
Block a user