minor fix
This commit is contained in:
@@ -48,7 +48,7 @@ Function FreshMirrorCreation {
|
||||
#compongo url da chiamare per creazione nuovo mirror
|
||||
$callUrlCreateMirror = "https://gitlab.steamware.net/api/v4/projects/" + $projectNumber + "/remote_mirrors"
|
||||
#creo url del nuovo mirror con username e token relativi a gitlab
|
||||
$newMirror = "https://" + $user + ":" + $auth + "@" + $destination + "/" + $path
|
||||
$newMirror = "http://" + $user + ":" + $auth + "@" + $destination + "/" + $path
|
||||
#creo body da convertire in json
|
||||
$body =
|
||||
@{
|
||||
@@ -69,3 +69,14 @@ Function FreshMirrorCreation {
|
||||
#scrivo ID e URL nuovo mirror
|
||||
WriteLogOutput $logFile 1 "NEW ID: $mirrorId - URL: $mirrorUrl - Mirror creato con successo"
|
||||
}
|
||||
|
||||
Function TryParse-Json {
|
||||
param([string]$InputString)
|
||||
|
||||
try {
|
||||
return $InputString | ConvertFrom-Json -ErrorAction Stop
|
||||
}
|
||||
catch {
|
||||
return $null
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,8 @@ $mainStopWatch = [system.diagnostics.stopwatch]::StartNew()
|
||||
$startProj = 1
|
||||
#numero massimo di progetti da analizzare
|
||||
$endProj = 300
|
||||
#contatore mirror creati
|
||||
$createdMirrors = 0
|
||||
#nome file di log
|
||||
$logFile = "NewMirrorsCreation.log"
|
||||
#nome file di log old
|
||||
@@ -61,27 +63,26 @@ for ($projectCount = $startProj; $projectCount -le $endProj; $projectCount++) {
|
||||
if ($gitlabResponse.Content -inotmatch "gitea.steamware.net") {
|
||||
#chiamo funzione per creare mirror verso gitea-steamware
|
||||
FreshMirrorCreation $projectCount $giteaSteamwUser $giteaSteamwPass $giteaSteamw $simplePath
|
||||
}
|
||||
#se la risposta non contiene "gitea-nembro" procedo a creare mirror relativo
|
||||
if ($gitlabResponse.Content -inotmatch "gitea-nembro.steamware.net") {
|
||||
#chiamo funzione per creare mirror verso gitea-nembro
|
||||
FreshMirrorCreation $projectCount $giteaNembroUser $giteaNembroPass $giteaNembro $simplePath
|
||||
$createdMirrors++
|
||||
}
|
||||
#se la risposta non contiene "gogs" procedo a creare mirror relativo
|
||||
if ($gitlabResponse.Content -inotmatch "gogs") {
|
||||
if ($gitlabResponse.Content -inotmatch "gogs.steamware.net") {
|
||||
#chiamo funzione per creare mirror verso gogs
|
||||
FreshMirrorCreation $projectCount $gogsUser $gogsPass $gogsDestination $simplePath
|
||||
$createdMirrors++
|
||||
}
|
||||
#se la risposta non contiene "gitlab-azzano" procedo a creare mirror relativo
|
||||
if ($gitlabResponse.Content -inotmatch "gitlab-azzano") {
|
||||
#chiamo funzione per creare mirror verso gitlab-azzano
|
||||
FreshMirrorCreation $projectCount $userName $tokenAzzano $destinationAzzano $simplePath
|
||||
#se la risposta non contiene "gitea-nembro" procedo a creare mirror relativo
|
||||
if ($gitlabResponse.Content -inotmatch "gitea-nembro") {
|
||||
#chiamo funzione per creare mirror verso gitea-nembro
|
||||
FreshMirrorCreation $projectCount $giteaNembroUser $giteaNembroPass $giteaNembro $simplePath
|
||||
$createdMirrors++
|
||||
}
|
||||
#se la risposta non contiene "gitea-azzano" procedo a creare mirror relativo
|
||||
if ($gitlabResponse.Content -inotmatch "gitea-azzano") {
|
||||
#chiamo funzione per creare mirror verso gitea-azzano
|
||||
FreshMirrorCreation $projectCount $giteaAzzanoUser $giteaAzzanoPass $giteaAzzano $simplePath
|
||||
$createdMirrors++
|
||||
}
|
||||
#OLD: se la risposta non contiene "gitlab-nembro" procedo a creare mirror relativo
|
||||
#if ($gitlabResponse.Content -inotmatch "gitlab-nembro") {
|
||||
# #chiamo funzione per creare mirror verso gitlab-nembro
|
||||
# FreshMirrorCreation $projectCount $userName $tokenNembro $destinationNembro $simplePath
|
||||
#}
|
||||
}
|
||||
#scrivo se trovo un errore durante il try/catch
|
||||
catch {
|
||||
@@ -103,6 +104,8 @@ $endTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss")
|
||||
|
||||
#scrivo a video le statistiche
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Nuovi mirror creati: $createdMirrors"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Fine Esecuzione Script: $endTime"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Durata Esecuzione Script: $durataScript secondi"
|
||||
|
||||
@@ -20,17 +20,18 @@ $logFile = "GiteaReposCreation.log"
|
||||
#nome file di log old
|
||||
$oldLogFile = "GiteaReposCreation.old"
|
||||
|
||||
#gitea di destinazione
|
||||
$target = "steamware"
|
||||
#$target = "nembro"
|
||||
|
||||
#creazione folder di Log se non esiste
|
||||
CheckLogFolder
|
||||
|
||||
#rotazione vecchio logFile da .log a .old se esiste
|
||||
RotateOldLog
|
||||
|
||||
if ($target = "steamware"){
|
||||
#gitea di destinazione
|
||||
#$target = "steamware"
|
||||
#$target = "nembro"
|
||||
$target = "azzano"
|
||||
|
||||
if ($target -eq "steamware"){
|
||||
#destinazione mirror per gitea Steamw
|
||||
$giteaDestination = $giteaSteamw
|
||||
#nome utente gitea Steamw che effettua i mirror push
|
||||
@@ -40,16 +41,26 @@ $giteaPass = $giteaSteamwPass
|
||||
#access token per autenticazione gitea Steamw da profilo replica
|
||||
$giteaHead = $giteaSteamwHead
|
||||
}
|
||||
#if ($target = "nembro") {
|
||||
if ($target -eq "nembro") {
|
||||
#destinazione mirror per gitea nembro
|
||||
#$giteaDestination = $giteaNembro
|
||||
$giteaDestination = $giteaNembro
|
||||
#nome utente gitea nembro che effettua i mirror push
|
||||
#$giteaUser = $giteaNembroUser
|
||||
$giteaUser = $giteaNembroUser
|
||||
#autenticazione replica gitea nembro
|
||||
#$giteaPass = $giteaNembroPass
|
||||
$giteaPass = $giteaNembroPass
|
||||
#access token per autenticazione gitea nembro da profilo replica
|
||||
#$giteaHead = $giteaNembroHead
|
||||
#}
|
||||
$giteaHead = $giteaNembroHead
|
||||
}
|
||||
if ($target -eq "azzano") {
|
||||
#destinazione mirror per gitea azzano
|
||||
$giteaDestination = $giteaAzzano
|
||||
#nome utente gitea azzano che effettua i mirror push
|
||||
$giteaUser = $giteaAzzanoUser
|
||||
#autenticazione replica gitea nemazzanobro
|
||||
$giteaPass = $giteaAzzanoPass
|
||||
#access token per autenticazione gitea azzano da profilo replica
|
||||
$giteaHead = $giteaAzzanoHead
|
||||
}
|
||||
|
||||
#scrivo intestazione e inizio analisi
|
||||
WriteLogOutput $logFile 0 "--------------------"
|
||||
@@ -76,7 +87,7 @@ for ($projectCount = $startProj; $projectCount -le $endProj; $projectCount++){
|
||||
WriteLogOutput $logFile 1 "**PROGETTO $projectCount**"
|
||||
foreach ($gitlabItem in $parsedGitlabResponse) {
|
||||
WriteLogOutput $logFile 1 "Gitlab Project Name: $($gitlabItem.name)"
|
||||
$callGiteaUrl = "https://" + $giteaDestination + "/api/v1/orgs/Egalware/repos"
|
||||
$callGiteaUrl = "http://" + $giteaDestination + "/api/v1/orgs/Egalware/repos"
|
||||
#dichiaro un body da convertire in JSON con il nome del repo da creare (prendo path o name a seconda delle necessità)
|
||||
$giteaBody =
|
||||
@{
|
||||
|
||||
Reference in New Issue
Block a user