Fix trunkate in renewgitlabmirroring
This commit is contained in:
@@ -21,7 +21,7 @@ $tokenNembro = "glpat-TzZkRUoYAdKikgwFXW_E"
|
||||
#contatore ciclo do while
|
||||
$projectCount = 1
|
||||
|
||||
#numero massimo di progetti da analizzare
|
||||
#numero massimo di progetti
|
||||
$projectNumber = 1
|
||||
|
||||
#livello di log: 0=log sintetico, 1=log errori, 2=log full, 3=log ampolloso
|
||||
@@ -99,27 +99,31 @@ do
|
||||
$doExecute = "false"
|
||||
$token = ""
|
||||
$mirrorUrl = ""
|
||||
$trunkedPath = ""
|
||||
#controllo se l'url del mirror contiene azzano
|
||||
if($item.url.Contains("azzano"))
|
||||
{
|
||||
$doExecute = "true"
|
||||
$token = $tokenAzzano
|
||||
$mirrorDestination = "@gitlab-azzano.steamware.net"
|
||||
}
|
||||
#controllo se l'url del mirror contiene nembro
|
||||
elseif($item.url.Contains("nembro"))
|
||||
{
|
||||
$doExecute = "true"
|
||||
$token = $tokenNembro
|
||||
$mirrorDestination = "@gitlab-nembro.steamware.net"
|
||||
}
|
||||
#verifico se i mirroring trovati per il progetto corrente contengono "azzano" nell'url
|
||||
#verifico se devo effettuare cancellazione e creazione nuovo mirror
|
||||
if($doExecute -eq "true")
|
||||
{
|
||||
#salvo id mirror e url mirror
|
||||
$mirrorId = $($item.id)
|
||||
$mirrorUrl = $($item.url)
|
||||
WriteLogOutput 1 "ID: $mirrorId - URL: $mirrorUrl"
|
||||
#tronco url fino a azzano
|
||||
$trunkedPath = $mirrorUrl.Remove(0, ($mirrorUrl.Length - 18))
|
||||
#tronco url fino a ".net"
|
||||
$splitUrl = $mirrorUrl -split '.steamware.net/'
|
||||
$trunkedPath = $splitUrl[1]
|
||||
#compongo URL per cancellare mirror con ID trovato
|
||||
$callUrlDeleteMirror = "https://gitlab.steamware.net/api/v4/projects/" + $projectCount + "/remote_mirrors/" + $mirrorId
|
||||
#chiamata api con method delete che cancella mirror con id specificato
|
||||
@@ -127,7 +131,7 @@ do
|
||||
#compongo url da chiamare per creazione nuovo mirror
|
||||
$callUrlCreateMirror = "https://gitlab.steamware.net/api/v4/projects/" + $projectCount + "/remote_mirrors"
|
||||
#creo url del nuovo mirror con username e token relativi a gitlab
|
||||
$newMirror = "https://" + $userName + ":" + $token + $mirrorDestination + $trunkedPath
|
||||
$newMirror = "https://" + $userName + ":" + $token + $mirrorDestination + "/" + $trunkedPath
|
||||
#creo body da convertire in json
|
||||
$body =
|
||||
@{
|
||||
@@ -138,7 +142,7 @@ do
|
||||
$jsonBody = ConvertTo-Json -InputObject $body
|
||||
#chiamata api POST che crea mirror con url e body specificati
|
||||
Invoke-WebRequest -Method Post -URI $callUrlCreateMirror -Headers $head -ContentType "application/json" -Body $jsonBody -UseBasicParsing
|
||||
WriteLogOutput 1 "Mirror $mirrorDestination$trunkedPath Ricostruito con successo"
|
||||
WriteLogOutput 1 "Mirror ricostruito con successo"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+10
-5
@@ -1,9 +1,14 @@
|
||||
|
||||
|
||||
|
||||
$head = @{"PRIVATE-TOKEN"="glpat-dQsUhS-GxNomkh1GnjHZ"}
|
||||
$projectCount=1
|
||||
#$head = @{"PRIVATE-TOKEN"="glpat-dQsUhS-GxNomkh1GnjHZ"}
|
||||
#$projectCount=1
|
||||
#$callUrl = "https://gitlab.steamware.net/api/v4/projects/" + $projectCount + "/remote_mirrors"
|
||||
$callUrl = "https://gitlab.steamware.net/"
|
||||
$Response = Invoke-WebRequest -URI $callUrl -Headers $head -ContentType "application/json" -UseBasicParsing
|
||||
Write-Output($Response)
|
||||
#$callUrl = "https://gitlab.steamware.net/"
|
||||
#$Response = Invoke-WebRequest -URI $callUrl -Headers $head -ContentType "application/json" -UseBasicParsing
|
||||
#Write-Output($Response)
|
||||
|
||||
$url = "https://*****:*****@gitlab-nembro.steamware.net/steamware/NKC.git"
|
||||
$splitUrl = $url -split '.net'
|
||||
Write-Output $splitUrl[0]
|
||||
Write-Output $splitUrl[1]
|
||||
Reference in New Issue
Block a user