Merge branch 'develop' into main
This commit is contained in:
@@ -15,7 +15,7 @@ $mainStopWatch = [system.diagnostics.stopwatch]::StartNew()
|
||||
#contatore ciclo do while
|
||||
$projectCount = 1
|
||||
#numero massimo di progetti da analizzare
|
||||
$projectNumber = 200
|
||||
$projectNumber = 300
|
||||
#conteggio progetti trovati
|
||||
$projectsFound = 0
|
||||
#conteggio progetti con commit negli ultimi giorni
|
||||
|
||||
@@ -15,7 +15,7 @@ $mainStopWatch = [system.diagnostics.stopwatch]::StartNew()
|
||||
#contatore ciclo do while
|
||||
$projectCount = 1
|
||||
#numero massimo di progetti da analizzare
|
||||
$projectNumber = 200
|
||||
$projectNumber = 300
|
||||
#conteggio progetti trovati
|
||||
$existingProjects = 0
|
||||
#conteggio mirroring in errore
|
||||
@@ -107,7 +107,7 @@ WriteLogOutput $logFile 0 ""
|
||||
& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "IIS04" -k Gitlab.SuccessMirrorPercent -o $mirrorSuccessPercentage
|
||||
& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "IIS04" -k Gitlab.ErrorsMirrorPercent -o $mirrorErrorsPercentage
|
||||
& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "IIS04" -k Gitlab.CheckMirrorDuration -o $durataScript
|
||||
|
||||
\
|
||||
#scrivo a video le statistiche
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "PROGETTI ANALIZZATI: $existingProjects"
|
||||
|
||||
@@ -13,9 +13,9 @@ $startTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss")
|
||||
# avvio stopwatch
|
||||
$mainStopWatch = [system.diagnostics.stopwatch]::StartNew()
|
||||
#contatore ciclo do while
|
||||
$projectCount = 170
|
||||
$projectCount = 0
|
||||
#numero massimo di progetti da analizzare
|
||||
$projectNumber = 250
|
||||
$projectNumber = 300
|
||||
#nome file di log
|
||||
$logFile = "GiteaNewMirrors.log"
|
||||
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
###Gitlab: forzo push verso i mirror dei singoli progetti###
|
||||
|
||||
#Questo script passa in rassegna tutti i progetti esistenti sul gitlab aziendale e per ognuno verifica lo stato dei mirror, poi forza il push di tutti.
|
||||
|
||||
#importo file contenente configurazioni
|
||||
. .\ApiGit\ApiGitResources\ApiScriptsConfig.ps1
|
||||
#importo file contenente funzioni
|
||||
. .\ApiGit\ApiGitResources\ApiScriptsFunctions.ps1
|
||||
|
||||
#rilevo time per log inizio analisi
|
||||
$startTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss")
|
||||
# avvio stopwatch
|
||||
$mainStopWatch = [system.diagnostics.stopwatch]::StartNew()
|
||||
#contatore ciclo do while
|
||||
$projectCount = 1
|
||||
#numero massimo di progetti
|
||||
$projectNumber = 300
|
||||
#conteggio progetti trovati
|
||||
$existingProjects = 0
|
||||
#contatore mirror trovati
|
||||
$mirrorCount = 0
|
||||
#nome file di log
|
||||
$logFile = "GitlabForcePushMirror.log"
|
||||
|
||||
#creazione folder di Log se non già esistente
|
||||
if (Test-Path $logFolder) {
|
||||
}
|
||||
else {
|
||||
New-Item $logFolder -ItemType Directory
|
||||
}
|
||||
|
||||
#scrivo intestazione e inizio analisi
|
||||
WriteLogOutput $logFile 0 "--------------------"
|
||||
Switch ($logLevel) {
|
||||
0 { WriteLogOutput $logFile 0 "LOG SINTETICO GITLAB FORCE PUSH MIRROR" }
|
||||
1 { WriteLogOutput $logFile 0 "LOG ERRORI GITLAB FORCE PUSH MIRROR" }
|
||||
2 { WriteLogOutput $logFile 0 "LOG FULL GITLAB FORCE PUSH MIRROR" }
|
||||
3 { WriteLogOutput $logFile 0 "LOG AMPOLLOSO GITLAB FORCE PUSH MIRROR" }
|
||||
}
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Percorso log: $logFolder"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Inizio Esecuzione Script: $startTime"
|
||||
|
||||
#ciclo principale do/while che cicla da 1 a N projectNumber
|
||||
do {
|
||||
#chiamata api che restituisce informazioni sullo stato dei mirror
|
||||
$callUrl = "https://gitlab.steamware.net/api/v4/projects/" + $projectCount + "/remote_mirrors"
|
||||
WriteLogOutput $logFile 1 ""
|
||||
WriteLogOutput $logFile 1 "--------------------"
|
||||
WriteLogOutput $logFile 1 "**PROGETTO $projectCount**"
|
||||
try {
|
||||
#parsing della risposta api convertita da json
|
||||
$Response = Invoke-WebRequest -URI $callUrl -Headers $gitlabHead -ContentType "application/json" -UseBasicParsing
|
||||
$parsedResponse = $Response.Content | ConvertFrom-Json
|
||||
#per ogni mirror forzo il push
|
||||
foreach ($item in $parsedResponse) {
|
||||
#compongo URL per chiamata POST per forzare PUSH
|
||||
$callUrlForcePush = "https://gitlab.steamware.net/api/v4/projects/" + $projectCount + "/remote_mirrors/" + $item.id + "/sync"
|
||||
$PushResponse = Invoke-WebRequest -URI $callUrlForcePush -Method POST -Headers $gitlabHead -ContentType "application/json" -UseBasicParsing
|
||||
if ($PushResponse.StatusCode -eq 204){
|
||||
WriteLogOutput $logFile 0 $("Mirror Push: Success - " + $item.url)
|
||||
}
|
||||
else {
|
||||
WriteLogOutput $logFile 0 $("Mirror Push: Unknown - " + $item.url)
|
||||
}
|
||||
$mirrorCount = $mirrorCount + 1
|
||||
}
|
||||
$existingProjects = $existingProjects + 1
|
||||
}
|
||||
#scrivo se trovo un errore durante il try/catch
|
||||
catch {
|
||||
$parsedError = $_ | ConvertFrom-Json
|
||||
WriteLogOutput $logFile 3 $($parsedError.message)
|
||||
}
|
||||
$projectCount = $projectCount + 1
|
||||
}
|
||||
#fine ciclo principale
|
||||
while ($projectCount -le $projectNumber)
|
||||
|
||||
# fermo stopwatch e calcolo durata script
|
||||
$mainStopWatch.Stop()
|
||||
$durataScript = $mainStopWatch.Elapsed.TotalSeconds
|
||||
|
||||
#rilevo time per log fine analisi
|
||||
$endTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss")
|
||||
|
||||
#scrivo a video le statistiche
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "PROGETTI ANALIZZATI: $existingProjects"
|
||||
WriteLogOutput $logFile 0 "MIRRORING TOTALI: $mirrorCount"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Fine Esecuzione Script: $endTime"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Durata Esecuzione Script: $durataScript secondi"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
+6
-4
@@ -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) {
|
||||
@@ -50,6 +50,8 @@ WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Percorso log: $logFolder"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Inizio Esecuzione Script: $startTime"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Gitlab di Destinazione: $gitlabIstance"
|
||||
|
||||
#ciclo principale do/while che cicla da 1 a N projectNumber
|
||||
do {
|
||||
@@ -15,7 +15,7 @@ $mainStopWatch = [system.diagnostics.stopwatch]::StartNew()
|
||||
#contatore ciclo do while
|
||||
$projectCount = 1
|
||||
#numero massimo di progetti da analizzare
|
||||
$projectNumber = 200
|
||||
$projectNumber = 300
|
||||
#nome file di log
|
||||
$logFile = "GitlabDevelopCreation.log"
|
||||
|
||||
@@ -16,7 +16,7 @@ $mainStopWatch = [system.diagnostics.stopwatch]::StartNew()
|
||||
#contatore ciclo do while
|
||||
$projectCount = 1
|
||||
#numero massimo di progetti da analizzare
|
||||
$projectNumber = 200
|
||||
$projectNumber = 300
|
||||
#nome file di log
|
||||
$logFile = "GitlabTagCreation.log"
|
||||
|
||||
@@ -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 = 170
|
||||
$projectCount = 1
|
||||
#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 (legge file config)
|
||||
$gitlabIstance = $destinationNembro
|
||||
$destinationHead = $nembroHead
|
||||
#$gitlabIstance = $destinationAzzano
|
||||
#$destinationHead = $azzanoHead
|
||||
|
||||
#creazione folder di Log se non già esistente
|
||||
if (Test-Path $logFolder) {
|
||||
}
|
||||
@@ -43,41 +49,33 @@ 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
|
||||
$body =
|
||||
@{
|
||||
name = $($parsedGitlabResponse.path);
|
||||
#name = $($parsedGitlabResponse.name);
|
||||
namespace_id = 19
|
||||
name = $($parsedGitlabResponse.path);
|
||||
#(namespace_id 19 è Egalware)
|
||||
namespace_id = 19
|
||||
}
|
||||
# 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
|
||||
}
|
||||
|
||||
@@ -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 = 170
|
||||
$projectCount = 1
|
||||
#numero massimo di progetti da analizzare
|
||||
$projectNumber = 300
|
||||
#nome file di log
|
||||
|
||||
@@ -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 = 170
|
||||
$projectCount = 1
|
||||
#numero massimo di progetti da analizzare
|
||||
$projectNumber = 300
|
||||
#nome file di log
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
###ESEMPIO COMANDO ROBOCOPY###
|
||||
|
||||
#path cartella di origine
|
||||
$sourceFolder = "C:\Users\YYY"
|
||||
|
||||
#nomi dei file da copiare
|
||||
$file1 = "nome1.txt"
|
||||
$file2 = "nome2.txt"
|
||||
$file3 = "nome3.txt"
|
||||
|
||||
#path delle cartelle di destinazione
|
||||
$destFolder1 = "C:\Users\XXX1"
|
||||
$destFolder2 = "C:\Users\XXX2"
|
||||
$destFolder3 = "C:\Users\XXX3"
|
||||
|
||||
#copio primo file
|
||||
robocopy $sourceFolder $destFolder1 $file1
|
||||
#copio secondo file
|
||||
robocopy $sourceFolder $destFolder2 $file2
|
||||
#copio terzo file
|
||||
robocopy $sourceFolder $destFolder3 $file3
|
||||
@@ -1,6 +0,0 @@
|
||||
#Eseguo Get-Service per ottenere informazioni riguardo il servizio desiderato
|
||||
$Response = Get-Service "NomeServizio"
|
||||
#Se il servizio ha status = stopped faccio qualcosa tipo inviare a zabbix informazioni
|
||||
if ($Response.Status -eq "Stopped" ) {
|
||||
#& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ovh -s "WIN2019IIS.OVH" -k RedisSentinel.Failure -o 1
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#Eseguo Get-Service per ottenere informazioni riguardo il servizio desiderato
|
||||
$Response = Get-Service "Redis Sentinel"
|
||||
#Se il servizio ha status = stopped faccio qualcosa tipo inviare a zabbix informazioni
|
||||
if ($Response.Status -eq "Running" ) {
|
||||
& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ovh -s "WIN2019IIS.OVH" -k RedisSentinel.Failure -o 0
|
||||
echo 0
|
||||
}
|
||||
else {
|
||||
& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ovh -s "WIN2019IIS.OVH" -k RedisSentinel.Failure -o 1
|
||||
echo 1
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#Eseguo Get-Service per ottenere informazioni riguardo il servizio desiderato
|
||||
$Response = Get-Service "Redis"
|
||||
#Se il servizio ha status = stopped faccio qualcosa tipo inviare a zabbix informazioni
|
||||
if ($Response.Status -eq "Running" ) {
|
||||
& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ovh -s "WIN2019IIS.OVH" -k Redis.Failure -o 0
|
||||
echo 0
|
||||
}
|
||||
else {
|
||||
& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ovh -s "WIN2019IIS.OVH" -k Redis.Failure -o 1
|
||||
echo 1
|
||||
}
|
||||
Reference in New Issue
Block a user