diff --git a/ApiGit/Mirrors/CheckGitlabMirroring.ps1 b/ApiGit/Mirrors/CheckGitlabMirroring.ps1 index 24ab53a..73bc2a5 100644 --- a/ApiGit/Mirrors/CheckGitlabMirroring.ps1 +++ b/ApiGit/Mirrors/CheckGitlabMirroring.ps1 @@ -13,7 +13,7 @@ $startTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss") # avvio stopwatch $mainStopWatch = [system.diagnostics.stopwatch]::StartNew() #contatore ciclo do while -$projectCount = 1 +$projectCount = 0 #numero massimo di progetti da analizzare $projectNumber = 300 #conteggio progetti trovati diff --git a/ApiGit/Mirrors/GitlabCreateMissingMirrors.ps1 b/ApiGit/Mirrors/GitlabCreateMissingMirrors.ps1 index 008b41f..76385dd 100644 --- a/ApiGit/Mirrors/GitlabCreateMissingMirrors.ps1 +++ b/ApiGit/Mirrors/GitlabCreateMissingMirrors.ps1 @@ -13,7 +13,7 @@ $startTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss") # avvio stopwatch $mainStopWatch = [system.diagnostics.stopwatch]::StartNew() #contatore ciclo do while -$projectCount = 1 +$projectCount = 0 #numero massimo di progetti da analizzare $projectNumber = 300 #nome file di log diff --git a/ApiGit/Mirrors/GitlabForcePushMirror.ps1 b/ApiGit/Mirrors/GitlabForcePushMirror.ps1 index 8eb1550..d15eaba 100644 --- a/ApiGit/Mirrors/GitlabForcePushMirror.ps1 +++ b/ApiGit/Mirrors/GitlabForcePushMirror.ps1 @@ -12,7 +12,7 @@ $startTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss") # avvio stopwatch $mainStopWatch = [system.diagnostics.stopwatch]::StartNew() #contatore ciclo do while -$projectCount = 200 +$projectCount = 1 #numero massimo di progetti $projectNumber = 300 #conteggio progetti trovati diff --git a/ApiGit/Misc/CheckGitlabProtectedBranches.ps1 b/ApiGit/Misc/CheckGitlabProtectedBranches.ps1 index 5cabdda..bd119e0 100644 --- a/ApiGit/Misc/CheckGitlabProtectedBranches.ps1 +++ b/ApiGit/Misc/CheckGitlabProtectedBranches.ps1 @@ -13,7 +13,7 @@ $startTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss") # avvio stopwatch $mainStopWatch = [system.diagnostics.stopwatch]::StartNew() #contatore ciclo do while -$projectCount = 200 +$projectCount = 1 #numero massimo di progetti da analizzare $projectNumber = 300 #conteggio progetti trovati @@ -26,10 +26,10 @@ $deleteProtection = 1 $logFile = "GitlabProtectedBranches.log" #specifica quale installazione di gitlab va controllata -$gitlabIstance = $destinationNembro -$head = $nembroHead -#$gitlabIstance = $destinationAzzano -#$head = $azzanoHead +#$gitlabIstance = $destinationNembro +#$head = $nembroHead +$gitlabIstance = $destinationAzzano +$head = $azzanoHead #creazione folder di Log se non già esistente if (Test-Path $logFolder) { diff --git a/ApiGit/ReposCreation/ReposCreationAzzanoNembro.ps1 b/ApiGit/ReposCreation/ReposCreationAzzanoNembro.ps1 index 5bb554b..c416416 100644 --- a/ApiGit/ReposCreation/ReposCreationAzzanoNembro.ps1 +++ b/ApiGit/ReposCreation/ReposCreationAzzanoNembro.ps1 @@ -13,12 +13,18 @@ $startTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss") # avvio stopwatch $mainStopWatch = [system.diagnostics.stopwatch]::StartNew() #contatore ciclo do while -$projectCount = 200 +$projectCount = 0 #numero massimo di progetti da analizzare (messo a 1 per "sicura inserita" siccome questo script è potenzialmente pericoloso) $projectNumber = 300 #nome file di log $logFile = "AzzanoNembroReposCreation.log" +#specifica su quale installazione di gitlab va eseguita la creazione +$gitlabIstance = $destinationNembro +$destinationHead = $nembroHead +#$gitlabIstance = $destinationAzzano +#$destinationHead = $azzanoHead + #creazione folder di Log se non già esistente if (Test-Path $logFolder) { } @@ -43,6 +49,10 @@ WriteLogOutput $logFile 0 "Inizio Esecuzione Script: $startTime" do { $callGitlabUrl = "https://gitlab.steamware.net/api/v4/projects/" + $projectCount try { + #scrivo il numero del progetto nel terminale e su file + WriteLogOutput $logFile 1 "" + WriteLogOutput $logFile 1 "--------------------" + WriteLogOutput $logFile 1 "**PROGETTO $projectCount**" $gitlabResponse = Invoke-WebRequest -URI $callGitlabUrl -Headers $gitlabHead -ContentType "application/json" -UseBasicParsing $parsedGitlabResponse = $gitlabResponse.Content | ConvertFrom-Json #dichiaro un body da convertire in JSON con il nome del repo da creare @@ -53,31 +63,19 @@ do { namespace_id = 19 #(namespace_id 19 è Egalware) } - # Converting my hash to json format - $bodyJSON = $body | ConvertTo-Json - #chiamata per nembro - $callNembroUrl = "https://gitlab-nembro.steamware.net/api/v4/projects/" - $nembroResponse = Invoke-WebRequest -URI $callNembroUrl -Method POST -Headers $nembroHead -ContentType "application/json" -Body $bodyJSON - $parsedNembroResponse = $nembroResponse.Content | ConvertFrom-Json - #chiamata per azzano - $callAzzanoUrl = "https://gitlab-azzano.steamware.net/api/v4/projects/" - $azzanoResponse = Invoke-WebRequest -URI $callAzzanoUrl -Method POST -Headers $azzanoHead -ContentType "application/json" -Body $bodyJSON - $parsedAzzanoResponse = $azzanoResponse.Content | ConvertFrom-Json - #scrivo il numero del progetto nel terminale e su file - WriteLogOutput $logFile 1 "" - WriteLogOutput $logFile 1 "--------------------" - WriteLogOutput $logFile 1 "**PROGETTO $projectCount**" + #scrivo il nome del progetto nel terminale e su file WriteLogOutput $logFile 1 "Gitlab Project Name: $($parsedGitlabResponse.path)" - WriteLogOutput $logFile 1 "Progetto creato su gitlab-nembro: $($parsedNembroResponse.path_with_namespace)" - WriteLogOutput $logFile 1 "Progetto creato su gitlab-azzano: $($parsedAzzanoResponse.path_with_namespace)" + $bodyJSON = $body | ConvertTo-Json + #chiamata creazione + $callUrl = "https://" + $gitlabIstance + "/api/v4/projects/" + $Response = Invoke-WebRequest -URI $callUrl -Method POST -Headers $destinationHead -ContentType "application/json" -Body $bodyJSON + $parsedResponse = $Response.Content | ConvertFrom-Json + WriteLogOutput $logFile 1 "Progetto creato su $callUrl : $($parsedResponse.path_with_namespace)" } #scrivo se trovo un errore durante il try/catch catch { $parsedError = $_ | ConvertFrom-Json - WriteLogOutput $logFile 3 "" - WriteLogOutput $logFile 3 "--------------------" - WriteLogOutput $logFile 3 "**ERRORE NEL PROGETTO $projectCount**" - WriteLogOutput $logFile 3 $($parsedError.message) + WriteLogOutput $logFile 3 "Errore: $($parsedError.message)" } $projectCount = $projectCount + 1 } diff --git a/ApiGit/ReposCreation/ReposCreationGitea.ps1 b/ApiGit/ReposCreation/ReposCreationGitea.ps1 index 0b84911..7b40652 100644 --- a/ApiGit/ReposCreation/ReposCreationGitea.ps1 +++ b/ApiGit/ReposCreation/ReposCreationGitea.ps1 @@ -12,7 +12,7 @@ $startTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss") # avvio stopwatch $mainStopWatch = [system.diagnostics.stopwatch]::StartNew() #contatore ciclo do while -$projectCount = 200 +$projectCount = 1 #numero massimo di progetti da analizzare $projectNumber = 300 #nome file di log diff --git a/ApiGit/ReposCreation/ReposCreationGogs.ps1 b/ApiGit/ReposCreation/ReposCreationGogs.ps1 index a0bdc8e..1d24570 100644 --- a/ApiGit/ReposCreation/ReposCreationGogs.ps1 +++ b/ApiGit/ReposCreation/ReposCreationGogs.ps1 @@ -12,7 +12,7 @@ $startTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss") # avvio stopwatch $mainStopWatch = [system.diagnostics.stopwatch]::StartNew() #contatore ciclo do while -$projectCount = 200 +$projectCount = 1 #numero massimo di progetti da analizzare $projectNumber = 300 #nome file di log