CI : Update agent from web
Some checks failed
release / build (push) Successful in 27s
release / verify-windows (push) Failing after 59s

This commit is contained in:
jeanotx32
2026-08-11 20:16:08 +02:00
parent 4f7b8f56ae
commit 6916ff4be3
8 changed files with 217 additions and 9 deletions

View File

@@ -129,6 +129,16 @@ if ($isUpgrade) {
}
$applied = @()
# Toujours rafraîchie : ce n'est pas de l'identité, c'est de l'infrastructure.
# Sans elle, l'agent ne saurait pas où chercher sa propre mise à jour.
if ($current.PSObject.Properties.Name -notcontains 'packageUrl') {
$current | Add-Member -NotePropertyName packageUrl -NotePropertyValue $url -Force
$applied += 'packageUrl'
} elseif ($current.packageUrl -ne $url) {
$current.packageUrl = $url
$applied += 'packageUrl'
}
if ($PSBoundParameters.ContainsKey('Server')) { $current.serverUrl = $Server; $applied += 'serverUrl' }
if ($PSBoundParameters.ContainsKey('Name')) { $current.name = $Name; $applied += 'name' }
if ($PSBoundParameters.ContainsKey('ObsHost')) { $current.obs.host = $ObsHost; $applied += 'obs.host' }
@@ -151,10 +161,11 @@ if ($isUpgrade) {
Info 'Configuration mise à jour, identité de l''agent préservée'
} else {
$config = [ordered]@{
serverUrl = $Server
token = $Token
name = $Name
obs = [ordered]@{ host = $ObsHost; port = $ObsPort; password = $ObsPassword }
serverUrl = $Server
token = $Token
name = $Name
packageUrl = $url
obs = [ordered]@{ host = $ObsHost; port = $ObsPort; password = $ObsPassword }
}
# Surtout pas Set-Content -Encoding UTF8 : sous PowerShell 5.1 il préfixe un
# BOM, et JSON.parse côté Node refuse le fichier.