chore: organize loose scripts into scripts/auto-organized
This commit is contained in:
parent
47feb3c7bf
commit
80ad669dae
67 changed files with 2928 additions and 0 deletions
38
scripts/auto-organized/approve_mfe_pipelines.ps1
Normal file
38
scripts/auto-organized/approve_mfe_pipelines.ps1
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp'
|
||||||
|
$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p))
|
||||||
|
$h = @{ Authorization = 'Basic ' + $t; 'Content-Type' = 'application/json' }
|
||||||
|
$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis'
|
||||||
|
|
||||||
|
# 1. Listar aprovacoes pendentes
|
||||||
|
Write-Host "Buscando aprovacoes pendentes..." -ForegroundColor Cyan
|
||||||
|
$approvals = Invoke-RestMethod -Uri "$base/pipelines/approvals?state=pending&api-version=7.1-preview.1" -Headers $h
|
||||||
|
|
||||||
|
if ($approvals.count -eq 0) {
|
||||||
|
Write-Host "Nenhuma aprovacao pendente no momento." -ForegroundColor Yellow
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "Encontradas $($approvals.count) aprovacao(oes) pendente(s):" -ForegroundColor Green
|
||||||
|
$approvals.value | ForEach-Object {
|
||||||
|
Write-Host " ID: $($_.id) | Pipeline: $($_.pipeline.name) | Stage: $($_.steps[0].actualApprover.displayName)" -ForegroundColor White
|
||||||
|
}
|
||||||
|
|
||||||
|
# 2. Aprovar todas
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "Aprovando todas..." -ForegroundColor Cyan
|
||||||
|
|
||||||
|
$items = @($approvals.value | ForEach-Object {
|
||||||
|
@{ approvalId = $_.id; status = 'approved'; comment = 'Aprovado automaticamente via API' }
|
||||||
|
})
|
||||||
|
$body = ConvertTo-Json -InputObject $items -Depth 5
|
||||||
|
|
||||||
|
$result = Invoke-RestMethod `
|
||||||
|
-Uri "$base/pipelines/approvals?api-version=7.1-preview.1" `
|
||||||
|
-Method PATCH -Headers $h -Body $body
|
||||||
|
|
||||||
|
$result.value | ForEach-Object {
|
||||||
|
Write-Host " $($_.id) -> $($_.status)" -ForegroundColor Green
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "Concluido." -ForegroundColor Green
|
||||||
BIN
scripts/auto-organized/bs_inspect.json
Normal file
BIN
scripts/auto-organized/bs_inspect.json
Normal file
Binary file not shown.
BIN
scripts/auto-organized/bs_labels.json
Normal file
BIN
scripts/auto-organized/bs_labels.json
Normal file
Binary file not shown.
97
scripts/auto-organized/bs_parsed.yaml
Normal file
97
scripts/auto-organized/bs_parsed.yaml
Normal file
|
|
@ -0,0 +1,97 @@
|
||||||
|
services:
|
||||||
|
bookstack:
|
||||||
|
image: 'lscr.io/linuxserver/bookstack:latest'
|
||||||
|
container_name: bookstack-ogs4okgoosk48cswoo0s4k84
|
||||||
|
environment:
|
||||||
|
PUID: '1000'
|
||||||
|
PGID: '1000'
|
||||||
|
APP_URL: 'https://docs.rede5.com.br'
|
||||||
|
DB_HOST: bookstack-db
|
||||||
|
DB_USER: bookstack
|
||||||
|
DB_PASS: bookstack_pass
|
||||||
|
DB_DATABASE: bookstackapp
|
||||||
|
COOLIFY_RESOURCE_UUID: ogs4okgoosk48cswoo0s4k84
|
||||||
|
COOLIFY_CONTAINER_NAME: bookstack-ogs4okgoosk48cswoo0s4k84
|
||||||
|
COOLIFY_FQDN: bookstack-ogs4okgoosk48cswoo0s4k84.185.194.141.70.sslip.io
|
||||||
|
COOLIFY_URL: 'http://bookstack-ogs4okgoosk48cswoo0s4k84.185.194.141.70.sslip.io'
|
||||||
|
SERVICE_NAME_BOOKSTACK: bookstack
|
||||||
|
SERVICE_NAME_MARIADB: mariadb
|
||||||
|
volumes:
|
||||||
|
- 'ogs4okgoosk48cswoo0s4k84_bookstack-config:/config'
|
||||||
|
depends_on:
|
||||||
|
- mariadb
|
||||||
|
restart: unless-stopped
|
||||||
|
labels:
|
||||||
|
- coolify.managed=true
|
||||||
|
- coolify.version=4.0.0-beta.463
|
||||||
|
- coolify.serviceId=5
|
||||||
|
- coolify.type=service
|
||||||
|
- coolify.name=bookstack-ogs4okgoosk48cswoo0s4k84
|
||||||
|
- coolify.resourceName=bookstack
|
||||||
|
- coolify.projectName=shared
|
||||||
|
- coolify.serviceName=bookstack
|
||||||
|
- coolify.environmentName=production
|
||||||
|
- coolify.pullRequestId=0
|
||||||
|
- coolify.service.subId=18
|
||||||
|
- coolify.service.subType=application
|
||||||
|
- coolify.service.subName=bookstack
|
||||||
|
- traefik.enable=true
|
||||||
|
- traefik.http.middlewares.gzip.compress=true
|
||||||
|
- traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https
|
||||||
|
- traefik.http.routers.http-0-ogs4okgoosk48cswoo0s4k84-bookstack.entryPoints=http
|
||||||
|
- traefik.http.routers.http-0-ogs4okgoosk48cswoo0s4k84-bookstack.middlewares=gzip
|
||||||
|
- 'traefik.http.routers.http-0-ogs4okgoosk48cswoo0s4k84-bookstack.rule=Host(`bookstack-ogs4okgoosk48cswoo0s4k84.185.194.141.70.sslip.io`) && PathPrefix(`/`)'
|
||||||
|
- 'caddy_0.encode=zstd gzip'
|
||||||
|
- 'caddy_0.handle_path.0_reverse_proxy={{upstreams 80}}'
|
||||||
|
- 'caddy_0.handle_path=/*'
|
||||||
|
- caddy_0.header=-Server
|
||||||
|
- 'caddy_0.try_files={path} /index.html /index.php'
|
||||||
|
- 'caddy_0=http://bookstack-ogs4okgoosk48cswoo0s4k84.185.194.141.70.sslip.io'
|
||||||
|
- caddy_ingress_network=ogs4okgoosk48cswoo0s4k84
|
||||||
|
networks:
|
||||||
|
ogs4okgoosk48cswoo0s4k84: null
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
|
mariadb:
|
||||||
|
image: 'mariadb:10.11'
|
||||||
|
container_name: mariadb-ogs4okgoosk48cswoo0s4k84
|
||||||
|
environment:
|
||||||
|
MYSQL_ROOT_PASSWORD: bookstack_root
|
||||||
|
MYSQL_DATABASE: bookstackapp
|
||||||
|
MYSQL_USER: bookstack
|
||||||
|
MYSQL_PASSWORD: bookstack_pass
|
||||||
|
COOLIFY_RESOURCE_UUID: ogs4okgoosk48cswoo0s4k84
|
||||||
|
COOLIFY_CONTAINER_NAME: mariadb-ogs4okgoosk48cswoo0s4k84
|
||||||
|
SERVICE_NAME_BOOKSTACK: bookstack
|
||||||
|
SERVICE_NAME_MARIADB: mariadb
|
||||||
|
volumes:
|
||||||
|
- 'ogs4okgoosk48cswoo0s4k84_bookstack-db:/var/lib/mysql'
|
||||||
|
restart: unless-stopped
|
||||||
|
labels:
|
||||||
|
- coolify.managed=true
|
||||||
|
- coolify.version=4.0.0-beta.463
|
||||||
|
- coolify.serviceId=5
|
||||||
|
- coolify.type=service
|
||||||
|
- coolify.name=mariadb-ogs4okgoosk48cswoo0s4k84
|
||||||
|
- coolify.resourceName=bookstack
|
||||||
|
- coolify.projectName=shared
|
||||||
|
- coolify.serviceName=mariadb
|
||||||
|
- coolify.environmentName=production
|
||||||
|
- coolify.pullRequestId=0
|
||||||
|
- coolify.service.subId=2
|
||||||
|
- coolify.service.subType=database
|
||||||
|
- coolify.service.subName=mariadb
|
||||||
|
networks:
|
||||||
|
ogs4okgoosk48cswoo0s4k84: null
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
|
volumes:
|
||||||
|
ogs4okgoosk48cswoo0s4k84_bookstack-config:
|
||||||
|
name: ogs4okgoosk48cswoo0s4k84_bookstack-config
|
||||||
|
ogs4okgoosk48cswoo0s4k84_bookstack-db:
|
||||||
|
name: ogs4okgoosk48cswoo0s4k84_bookstack-db
|
||||||
|
networks:
|
||||||
|
ogs4okgoosk48cswoo0s4k84:
|
||||||
|
name: ogs4okgoosk48cswoo0s4k84
|
||||||
|
external: true
|
||||||
|
|
||||||
104
scripts/auto-organized/bs_parsed_v2.yaml
Normal file
104
scripts/auto-organized/bs_parsed_v2.yaml
Normal file
|
|
@ -0,0 +1,104 @@
|
||||||
|
services:
|
||||||
|
bookstack:
|
||||||
|
image: 'lscr.io/linuxserver/bookstack:latest'
|
||||||
|
container_name: bookstack-ogs4okgoosk48cswoo0s4k84
|
||||||
|
environment:
|
||||||
|
PUID: '1000'
|
||||||
|
PGID: '1000'
|
||||||
|
APP_URL: 'https://docs.rede5.com.br'
|
||||||
|
DB_HOST: bookstack-db
|
||||||
|
DB_USER: bookstack
|
||||||
|
DB_PASS: bookstack_pass
|
||||||
|
DB_DATABASE: bookstackapp
|
||||||
|
COOLIFY_RESOURCE_UUID: ogs4okgoosk48cswoo0s4k84
|
||||||
|
COOLIFY_CONTAINER_NAME: bookstack-ogs4okgoosk48cswoo0s4k84
|
||||||
|
COOLIFY_FQDN: bookstack-ogs4okgoosk48cswoo0s4k84.185.194.141.70.sslip.io
|
||||||
|
COOLIFY_URL: 'http://bookstack-ogs4okgoosk48cswoo0s4k84.185.194.141.70.sslip.io'
|
||||||
|
SERVICE_NAME_BOOKSTACK: bookstack
|
||||||
|
SERVICE_NAME_MARIADB: mariadb
|
||||||
|
volumes:
|
||||||
|
- 'ogs4okgoosk48cswoo0s4k84_bookstack-config:/config'
|
||||||
|
depends_on:
|
||||||
|
- mariadb
|
||||||
|
labels:
|
||||||
|
- coolify.managed=true
|
||||||
|
- traefik.enable=true
|
||||||
|
- traefik.http.routers.bookstack-https.rule=Host(`docs.rede5.com.br`)
|
||||||
|
- traefik.http.routers.bookstack-https.entrypoints=https
|
||||||
|
- traefik.http.routers.bookstack-https.tls=true
|
||||||
|
- traefik.http.routers.bookstack-https.tls.certresolver=letsencrypt
|
||||||
|
- traefik.http.services.bookstack-https.loadbalancer.server.port=80
|
||||||
|
- coolify.managed=true
|
||||||
|
- coolify.version=4.0.0-beta.463
|
||||||
|
- coolify.serviceId=5
|
||||||
|
- coolify.type=service
|
||||||
|
- coolify.name=bookstack-ogs4okgoosk48cswoo0s4k84
|
||||||
|
- coolify.resourceName=bookstack
|
||||||
|
- coolify.projectName=shared
|
||||||
|
- coolify.serviceName=bookstack
|
||||||
|
- coolify.environmentName=production
|
||||||
|
- coolify.pullRequestId=0
|
||||||
|
- coolify.service.subId=18
|
||||||
|
- coolify.service.subType=application
|
||||||
|
- coolify.service.subName=bookstack
|
||||||
|
- traefik.enable=true
|
||||||
|
- traefik.http.middlewares.gzip.compress=true
|
||||||
|
- traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https
|
||||||
|
- traefik.http.routers.http-0-ogs4okgoosk48cswoo0s4k84-bookstack.entryPoints=http
|
||||||
|
- traefik.http.routers.http-0-ogs4okgoosk48cswoo0s4k84-bookstack.middlewares=gzip
|
||||||
|
- 'traefik.http.routers.http-0-ogs4okgoosk48cswoo0s4k84-bookstack.rule=Host(`bookstack-ogs4okgoosk48cswoo0s4k84.185.194.141.70.sslip.io`) && PathPrefix(`/`)'
|
||||||
|
- 'caddy_0.encode=zstd gzip'
|
||||||
|
- 'caddy_0.handle_path.0_reverse_proxy={{upstreams 80}}'
|
||||||
|
- 'caddy_0.handle_path=/*'
|
||||||
|
- caddy_0.header=-Server
|
||||||
|
- 'caddy_0.try_files={path} /index.html /index.php'
|
||||||
|
- 'caddy_0=http://bookstack-ogs4okgoosk48cswoo0s4k84.185.194.141.70.sslip.io'
|
||||||
|
- caddy_ingress_network=ogs4okgoosk48cswoo0s4k84
|
||||||
|
restart: unless-stopped
|
||||||
|
networks:
|
||||||
|
ogs4okgoosk48cswoo0s4k84: null
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
|
mariadb:
|
||||||
|
image: 'mariadb:10.11'
|
||||||
|
container_name: mariadb-ogs4okgoosk48cswoo0s4k84
|
||||||
|
environment:
|
||||||
|
MYSQL_ROOT_PASSWORD: bookstack_root
|
||||||
|
MYSQL_DATABASE: bookstackapp
|
||||||
|
MYSQL_USER: bookstack
|
||||||
|
MYSQL_PASSWORD: bookstack_pass
|
||||||
|
COOLIFY_RESOURCE_UUID: ogs4okgoosk48cswoo0s4k84
|
||||||
|
COOLIFY_CONTAINER_NAME: mariadb-ogs4okgoosk48cswoo0s4k84
|
||||||
|
SERVICE_NAME_BOOKSTACK: bookstack
|
||||||
|
SERVICE_NAME_MARIADB: mariadb
|
||||||
|
volumes:
|
||||||
|
- 'ogs4okgoosk48cswoo0s4k84_bookstack-db:/var/lib/mysql'
|
||||||
|
restart: unless-stopped
|
||||||
|
labels:
|
||||||
|
- coolify.managed=true
|
||||||
|
- coolify.version=4.0.0-beta.463
|
||||||
|
- coolify.serviceId=5
|
||||||
|
- coolify.type=service
|
||||||
|
- coolify.name=mariadb-ogs4okgoosk48cswoo0s4k84
|
||||||
|
- coolify.resourceName=bookstack
|
||||||
|
- coolify.projectName=shared
|
||||||
|
- coolify.serviceName=mariadb
|
||||||
|
- coolify.environmentName=production
|
||||||
|
- coolify.pullRequestId=0
|
||||||
|
- coolify.service.subId=2
|
||||||
|
- coolify.service.subType=database
|
||||||
|
- coolify.service.subName=mariadb
|
||||||
|
networks:
|
||||||
|
ogs4okgoosk48cswoo0s4k84: null
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
|
volumes:
|
||||||
|
ogs4okgoosk48cswoo0s4k84_bookstack-config:
|
||||||
|
name: ogs4okgoosk48cswoo0s4k84_bookstack-config
|
||||||
|
ogs4okgoosk48cswoo0s4k84_bookstack-db:
|
||||||
|
name: ogs4okgoosk48cswoo0s4k84_bookstack-db
|
||||||
|
networks:
|
||||||
|
ogs4okgoosk48cswoo0s4k84:
|
||||||
|
name: ogs4okgoosk48cswoo0s4k84
|
||||||
|
external: true
|
||||||
|
|
||||||
19
scripts/auto-organized/check_builds.ps1
Normal file
19
scripts/auto-organized/check_builds.ps1
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp'
|
||||||
|
$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p))
|
||||||
|
$h = @{ Authorization = 'Basic ' + $t }
|
||||||
|
$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis'
|
||||||
|
|
||||||
|
$mfes = @('mfe-shell','mfe-auth','mfe-user','mfe-person','mfe-poc')
|
||||||
|
|
||||||
|
foreach ($mfe in $mfes) {
|
||||||
|
$defs = Invoke-RestMethod -Uri "$base/build/definitions?name=$mfe&api-version=7.0" -Headers $h
|
||||||
|
if ($defs.count -eq 0) { Write-Host "$mfe sem definicao"; continue }
|
||||||
|
|
||||||
|
$defId = $defs.value[0].id
|
||||||
|
$builds = Invoke-RestMethod -Uri "$base/build/builds?definitions=$defId&branchName=refs/heads/devops&`$top=1&api-version=7.0" -Headers $h
|
||||||
|
if ($builds.count -eq 0) { Write-Host "$mfe sem builds"; continue }
|
||||||
|
|
||||||
|
$b = $builds.value[0]
|
||||||
|
$result = if ($b.result) { $b.result } else { '(running)' }
|
||||||
|
Write-Host "$mfe status=$($b.status) result=$result"
|
||||||
|
}
|
||||||
19
scripts/auto-organized/check_builds2.ps1
Normal file
19
scripts/auto-organized/check_builds2.ps1
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp'
|
||||||
|
$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p))
|
||||||
|
$h = @{ Authorization = 'Basic ' + $t }
|
||||||
|
$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis'
|
||||||
|
|
||||||
|
$mfes = @('mfe-shell','mfe-auth','mfe-user','mfe-person','mfe-poc')
|
||||||
|
|
||||||
|
foreach ($mfe in $mfes) {
|
||||||
|
$defs = Invoke-RestMethod -Uri "$base/build/definitions?name=$mfe&api-version=7.0" -Headers $h
|
||||||
|
if ($defs.count -eq 0) { Write-Host "$mfe sem definicao"; continue }
|
||||||
|
|
||||||
|
$defId = $defs.value[0].id
|
||||||
|
$builds = Invoke-RestMethod -Uri "$base/build/builds?definitions=$defId&branchName=refs/heads/devops&`$top=1&api-version=7.0" -Headers $h
|
||||||
|
if ($builds.count -eq 0) { Write-Host "$mfe sem builds"; continue }
|
||||||
|
|
||||||
|
$b = $builds.value[0]
|
||||||
|
$result = if ($b.result) { $b.result } else { '(running)' }
|
||||||
|
Write-Host "$mfe status=$($b.status) result=$result"
|
||||||
|
}
|
||||||
44
scripts/auto-organized/check_cf_dns.ps1
Normal file
44
scripts/auto-organized/check_cf_dns.ps1
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
$tokenPath = "$env:USERPROFILE\.ssh\cloudflare-token"
|
||||||
|
$CF_TOKEN = (Get-Content $tokenPath -Encoding UTF8 -Raw).Trim()
|
||||||
|
Write-Host "Token len: $($CF_TOKEN.Length) preview: $($CF_TOKEN.Substring(0,6))..."
|
||||||
|
|
||||||
|
$cfh = @{ Authorization = "Bearer $CF_TOKEN"; 'Content-Type' = 'application/json' }
|
||||||
|
|
||||||
|
# Zone ID
|
||||||
|
$zonesResp = Invoke-RestMethod "https://api.cloudflare.com/client/v4/zones?name=invista.com.br&per_page=1" -Headers $cfh
|
||||||
|
if (-not $zonesResp.success) {
|
||||||
|
Write-Host "ERRO ao buscar zone: $($zonesResp.errors | ConvertTo-Json)"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
$zoneId = $zonesResp.result[0].id
|
||||||
|
Write-Host "Zone ID: $zoneId"
|
||||||
|
Write-Host ""
|
||||||
|
|
||||||
|
# Records
|
||||||
|
foreach ($sub in @('crivo-dev', 'mfe-user-dev', 'mfe-shell-dev')) {
|
||||||
|
$name = "$sub.invista.com.br"
|
||||||
|
$resp = Invoke-RestMethod "https://api.cloudflare.com/client/v4/zones/$zoneId/dns_records?name=$name&per_page=10" -Headers $cfh
|
||||||
|
Write-Host "=== $name ==="
|
||||||
|
if ($resp.result.Count -eq 0) {
|
||||||
|
Write-Host " (sem record)"
|
||||||
|
} else {
|
||||||
|
$resp.result | ForEach-Object {
|
||||||
|
Write-Host " type=$($_.type) content=$($_.content) proxied=$($_.proxied)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Write-Host ""
|
||||||
|
}
|
||||||
|
|
||||||
|
# Tunnels
|
||||||
|
Write-Host "=== Cloudflare Tunnels (via zone) ==="
|
||||||
|
$accResp = Invoke-RestMethod "https://api.cloudflare.com/client/v4/zones/$zoneId" -Headers $cfh
|
||||||
|
$accountId = $accResp.result.account.id
|
||||||
|
Write-Host "Account ID: $accountId"
|
||||||
|
if ($accountId) {
|
||||||
|
$tuns = Invoke-RestMethod "https://api.cloudflare.com/client/v4/accounts/$accountId/cfd_tunnel?status=active&per_page=10" -Headers $cfh
|
||||||
|
if ($tuns.result.Count -eq 0) {
|
||||||
|
Write-Host " (nenhum tunnel ativo)"
|
||||||
|
} else {
|
||||||
|
$tuns.result | ForEach-Object { Write-Host " tunnel: $($_.name) id=$($_.id)" }
|
||||||
|
}
|
||||||
|
}
|
||||||
44
scripts/auto-organized/check_cf_dns2.ps1
Normal file
44
scripts/auto-organized/check_cf_dns2.ps1
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
$tokenPath = "$env:USERPROFILE\.ssh\cloudflare-token"
|
||||||
|
$CF_TOKEN = (Get-Content $tokenPath -Encoding UTF8 -Raw).Trim()
|
||||||
|
Write-Host "Token len: $($CF_TOKEN.Length) preview: $($CF_TOKEN.Substring(0,6))..."
|
||||||
|
|
||||||
|
$cfh = @{ Authorization = "Bearer $CF_TOKEN"; 'Content-Type' = 'application/json' }
|
||||||
|
|
||||||
|
# Zone ID
|
||||||
|
$zonesResp = Invoke-RestMethod "https://api.cloudflare.com/client/v4/zones?name=invista.com.br&per_page=1" -Headers $cfh
|
||||||
|
if (-not $zonesResp.success) {
|
||||||
|
Write-Host "ERRO ao buscar zone: $($zonesResp.errors | ConvertTo-Json)"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
$zoneId = $zonesResp.result[0].id
|
||||||
|
Write-Host "Zone ID: $zoneId"
|
||||||
|
Write-Host ""
|
||||||
|
|
||||||
|
# Records
|
||||||
|
foreach ($sub in @('crivo-dev', 'mfe-user-dev', 'mfe-shell-dev')) {
|
||||||
|
$name = "$sub.invista.com.br"
|
||||||
|
$resp = Invoke-RestMethod "https://api.cloudflare.com/client/v4/zones/$zoneId/dns_records?name=$name&per_page=10" -Headers $cfh
|
||||||
|
Write-Host "=== $name ==="
|
||||||
|
if ($resp.result.Count -eq 0) {
|
||||||
|
Write-Host " (sem record)"
|
||||||
|
} else {
|
||||||
|
$resp.result | ForEach-Object {
|
||||||
|
Write-Host " type=$($_.type) content=$($_.content) proxied=$($_.proxied)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Write-Host ""
|
||||||
|
}
|
||||||
|
|
||||||
|
# Tunnels
|
||||||
|
Write-Host "=== Cloudflare Tunnels (via zone) ==="
|
||||||
|
$accResp = Invoke-RestMethod "https://api.cloudflare.com/client/v4/zones/$zoneId" -Headers $cfh
|
||||||
|
$accountId = $accResp.result.account.id
|
||||||
|
Write-Host "Account ID: $accountId"
|
||||||
|
if ($accountId) {
|
||||||
|
$tuns = Invoke-RestMethod "https://api.cloudflare.com/client/v4/accounts/$accountId/cfd_tunnel?status=active&per_page=10" -Headers $cfh
|
||||||
|
if ($tuns.result.Count -eq 0) {
|
||||||
|
Write-Host " (nenhum tunnel ativo)"
|
||||||
|
} else {
|
||||||
|
$tuns.result | ForEach-Object { Write-Host " tunnel: $($_.name) id=$($_.id)" }
|
||||||
|
}
|
||||||
|
}
|
||||||
10
scripts/auto-organized/check_ms_pipeline.ps1
Normal file
10
scripts/auto-organized/check_ms_pipeline.ps1
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp'
|
||||||
|
$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p))
|
||||||
|
$h = @{ Authorization = 'Basic ' + $t; 'Content-Type' = 'application/json' }
|
||||||
|
$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis'
|
||||||
|
|
||||||
|
# Ler o azure-pipelines.yaml do ms-user (devops branch)
|
||||||
|
$repoId = '24bdf218-522a-45e2-8a31-96db3962997d' # ms-user
|
||||||
|
Write-Host "=== ms-user: azure-pipelines.yaml (branch devops) ===" -ForegroundColor Cyan
|
||||||
|
$content = Invoke-RestMethod -Uri "$base/git/repositories/$repoId/items?path=/azure-pipelines.yaml`&versionDescriptor.version=devops`&api-version=7.0" -Headers $h
|
||||||
|
Write-Host $content
|
||||||
23
scripts/auto-organized/check_oke.ps1
Normal file
23
scripts/auto-organized/check_oke.ps1
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp'
|
||||||
|
$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p))
|
||||||
|
$h = @{ Authorization = 'Basic ' + $t; 'Content-Type' = 'application/json' }
|
||||||
|
$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis'
|
||||||
|
$repoId = 'ae7542f8-d76e-4a45-b8b2-745e18cd2f26'
|
||||||
|
|
||||||
|
# Ler o script oci_kubeconfig.sh
|
||||||
|
Write-Host "=== cd/scripts/oci_kubeconfig.sh ===" -ForegroundColor Cyan
|
||||||
|
try {
|
||||||
|
$content = Invoke-RestMethod -Uri "$base/git/repositories/$repoId/items?path=/cd/scripts/oci_kubeconfig.sh`&versionDescriptor.version=main`&api-version=7.0" -Headers $h
|
||||||
|
Write-Host $content
|
||||||
|
} catch {
|
||||||
|
# tentar na raiz
|
||||||
|
$tree = Invoke-RestMethod -Uri "$base/git/repositories/$repoId/items?scopePath=/cd/scripts`&recursionLevel=OneLevel`&api-version=7.0" -Headers $h -ErrorAction SilentlyContinue
|
||||||
|
if ($tree) {
|
||||||
|
$tree.value | Select-Object path | Format-Table
|
||||||
|
} else {
|
||||||
|
Write-Host " pasta /cd/scripts nao encontrada"
|
||||||
|
# listar raiz
|
||||||
|
$root = Invoke-RestMethod -Uri "$base/git/repositories/$repoId/items?scopePath=/`&recursionLevel=OneLevel`&api-version=7.0" -Headers $h
|
||||||
|
$root.value | Select-Object path | Format-Table
|
||||||
|
}
|
||||||
|
}
|
||||||
25
scripts/auto-organized/check_oke2.ps1
Normal file
25
scripts/auto-organized/check_oke2.ps1
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp'
|
||||||
|
$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p))
|
||||||
|
$h = @{ Authorization = 'Basic ' + $t; 'Content-Type' = 'application/json' }
|
||||||
|
$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis'
|
||||||
|
$repoId = 'ae7542f8-d76e-4a45-b8b2-745e18cd2f26'
|
||||||
|
|
||||||
|
# Ler config/oke-clusters.json (mencionado no script)
|
||||||
|
Write-Host "=== config/oke-clusters.json ===" -ForegroundColor Cyan
|
||||||
|
try {
|
||||||
|
$content = Invoke-RestMethod -Uri "$base/git/repositories/$repoId/items?path=/config/oke-clusters.json`&versionDescriptor.version=main`&api-version=7.0" -Headers $h
|
||||||
|
Write-Host ($content | ConvertTo-Json -Depth 10)
|
||||||
|
} catch {
|
||||||
|
Write-Host " Arquivo nao encontrado, tentando /cd/config/..." -ForegroundColor Yellow
|
||||||
|
try {
|
||||||
|
$content2 = Invoke-RestMethod -Uri "$base/git/repositories/$repoId/items?path=/cd/config/oke-clusters.json`&versionDescriptor.version=main`&api-version=7.0" -Headers $h
|
||||||
|
Write-Host ($content2 | ConvertTo-Json -Depth 10)
|
||||||
|
} catch {
|
||||||
|
Write-Host " Nao encontrado tambem em /cd/config/" -ForegroundColor Yellow
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Mostrar toda a estrutura do repo
|
||||||
|
Write-Host "`n=== Estrutura raiz do repo ===" -ForegroundColor Cyan
|
||||||
|
$root = Invoke-RestMethod -Uri "$base/git/repositories/$repoId/items?scopePath=/`&recursionLevel=OneLevel`&api-version=7.0" -Headers $h
|
||||||
|
$root.value | Select-Object path, gitObjectType | Format-Table
|
||||||
12
scripts/auto-organized/check_oke3.ps1
Normal file
12
scripts/auto-organized/check_oke3.ps1
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp'
|
||||||
|
$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p))
|
||||||
|
$h = @{ Authorization = 'Basic ' + $t; 'Content-Type' = 'application/json' }
|
||||||
|
$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis'
|
||||||
|
$repoId = 'ae7542f8-d76e-4a45-b8b2-745e18cd2f26'
|
||||||
|
|
||||||
|
$script = Invoke-RestMethod -Uri "$base/git/repositories/$repoId/items?path=/cd/scripts/oci_kubeconfig.sh`&versionDescriptor.version=main`&api-version=7.0" -Headers $h
|
||||||
|
# Imprimir só a parte que resolve CLUSTER_ID
|
||||||
|
$lines = $script -split "`n"
|
||||||
|
$start = ($lines | Select-String -Pattern 'CLUSTER_ID|oke-clusters|OKE_CLUSTER_OCID' | Select-Object -First 1).LineNumber - 5
|
||||||
|
$end = [Math]::Min($start + 40, $lines.Count)
|
||||||
|
$lines[$start..$end] -join "`n"
|
||||||
18
scripts/auto-organized/check_oke4.ps1
Normal file
18
scripts/auto-organized/check_oke4.ps1
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp'
|
||||||
|
$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p))
|
||||||
|
$h = @{ Authorization = 'Basic ' + $t; 'Content-Type' = 'application/json' }
|
||||||
|
$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis'
|
||||||
|
$repoId = 'ae7542f8-d76e-4a45-b8b2-745e18cd2f26'
|
||||||
|
|
||||||
|
$script = Invoke-RestMethod -Uri "$base/git/repositories/$repoId/items?path=/cd/scripts/oci_kubeconfig.sh`&versionDescriptor.version=main`&api-version=7.0" -Headers $h
|
||||||
|
$lines = $script -split "`n"
|
||||||
|
# Pegar as linhas que mencionam CLUSTER_ID
|
||||||
|
for ($i = 0; $i -lt $lines.Count; $i++) {
|
||||||
|
if ($lines[$i] -match 'CLUSTER_ID|oke-clusters|OKE_CLUSTER') {
|
||||||
|
$from = [Math]::Max(0, $i - 1)
|
||||||
|
$to = [Math]::Min($lines.Count - 1, $i + 3)
|
||||||
|
Write-Host "--- linha $($i+1) ---"
|
||||||
|
$lines[$from..$to] -join "`n"
|
||||||
|
Write-Host ""
|
||||||
|
}
|
||||||
|
}
|
||||||
50
scripts/auto-organized/check_pr.ps1
Normal file
50
scripts/auto-organized/check_pr.ps1
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp'
|
||||||
|
$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p))
|
||||||
|
$h = @{ Authorization = 'Basic ' + $t; 'Content-Type' = 'application/json' }
|
||||||
|
$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis'
|
||||||
|
$repoId = 'ae7542f8-d76e-4a45-b8b2-745e18cd2f26'
|
||||||
|
$prId = 2135
|
||||||
|
|
||||||
|
# Verificar status do PR e policies
|
||||||
|
$pr = Invoke-RestMethod -Uri "$base/git/repositories/$repoId/pullrequests/$prId`?api-version=7.0" -Headers $h
|
||||||
|
Write-Host "PR Status: $($pr.status)"
|
||||||
|
Write-Host "Merge Status: $($pr.mergeStatus)"
|
||||||
|
Write-Host "Is Draft: $($pr.isDraft)"
|
||||||
|
|
||||||
|
# Verificar policy evaluations
|
||||||
|
$policies = Invoke-RestMethod -Uri "$base/policy/evaluations?artifactId=vstfs:///CodeReview/CodeReviewId/$(($base -split '/')[4])/$prId`&api-version=7.0-preview.1" -Headers $h -ErrorAction SilentlyContinue
|
||||||
|
if ($policies) {
|
||||||
|
Write-Host "`nPolicies bloqueando:"
|
||||||
|
$policies.value | Where-Object { $_.status -ne 'approved' } | ForEach-Object {
|
||||||
|
Write-Host " - $($_.configuration.type.displayName): $($_.status)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Tentar votar como aprovador
|
||||||
|
Write-Host "`nTentando aprovar o PR..."
|
||||||
|
$voteBody = @{ vote = 10 } | ConvertTo-Json
|
||||||
|
$vote = Invoke-RestMethod -Uri "$base/git/repositories/$repoId/pullrequests/$prId/reviewers/me?api-version=7.0" -Method PUT -Headers $h -Body $voteBody -ErrorAction SilentlyContinue
|
||||||
|
if ($vote) {
|
||||||
|
Write-Host " Voto: $($vote.vote)" -ForegroundColor Green
|
||||||
|
}
|
||||||
|
|
||||||
|
# Tentar completar novamente
|
||||||
|
$featureSha = '7a8a0128350d43d839118383414a1b0dc4f24e44'
|
||||||
|
$completeBody = @{
|
||||||
|
status = 'completed'
|
||||||
|
lastMergeSourceCommit = @{ commitId = $featureSha }
|
||||||
|
completionOptions = @{
|
||||||
|
mergeStrategy = 'squash'
|
||||||
|
deleteSourceBranch = $false
|
||||||
|
bypassPolicy = $true
|
||||||
|
bypassReason = 'Merge automatico via script de correcao de infra'
|
||||||
|
}
|
||||||
|
} | ConvertTo-Json -Depth 5
|
||||||
|
|
||||||
|
Write-Host "Tentando completar PR #$prId..."
|
||||||
|
try {
|
||||||
|
$result = Invoke-RestMethod -Uri "$base/git/repositories/$repoId/pullrequests/$prId`?api-version=7.0" -Method PATCH -Headers $h -Body $completeBody -ErrorAction Stop
|
||||||
|
Write-Host " Status apos PATCH: $($result.status)" -ForegroundColor Green
|
||||||
|
} catch {
|
||||||
|
Write-Host " ERRO: $_" -ForegroundColor Red
|
||||||
|
}
|
||||||
15
scripts/auto-organized/check_stage.ps1
Normal file
15
scripts/auto-organized/check_stage.ps1
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp'
|
||||||
|
$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p))
|
||||||
|
$h = @{ Authorization = 'Basic ' + $t }
|
||||||
|
$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis'
|
||||||
|
|
||||||
|
foreach ($buildId in @(6181, 6182, 6185, 6186)) {
|
||||||
|
$b = Invoke-RestMethod -Uri "$base/build/builds/$buildId`?api-version=7.0" -Headers $h
|
||||||
|
$tl = Invoke-RestMethod -Uri "$base/build/builds/$buildId/timeline?api-version=7.0" -Headers $h
|
||||||
|
|
||||||
|
$running = $tl.records | Where-Object { $_.state -eq 'inProgress' } | Select-Object -First 1
|
||||||
|
$last = $tl.records | Where-Object { $_.state -eq 'completed' } | Sort-Object finishTime | Select-Object -Last 1
|
||||||
|
|
||||||
|
$current = if ($running) { $running.name } elseif ($last) { $last.name } else { '?' }
|
||||||
|
Write-Host "$($b.definition.name) (build $buildId): $($b.status) — etapa atual: $current"
|
||||||
|
}
|
||||||
15
scripts/auto-organized/check_stage2.ps1
Normal file
15
scripts/auto-organized/check_stage2.ps1
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp'
|
||||||
|
$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p))
|
||||||
|
$h = @{ Authorization = 'Basic ' + $t }
|
||||||
|
$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis'
|
||||||
|
|
||||||
|
foreach ($buildId in @(6181, 6182, 6185, 6186)) {
|
||||||
|
$b = Invoke-RestMethod -Uri "$base/build/builds/$buildId`?api-version=7.0" -Headers $h
|
||||||
|
$tl = Invoke-RestMethod -Uri "$base/build/builds/$buildId/timeline?api-version=7.0" -Headers $h
|
||||||
|
|
||||||
|
$running = $tl.records | Where-Object { $_.state -eq 'inProgress' } | Select-Object -First 1
|
||||||
|
$last = $tl.records | Where-Object { $_.state -eq 'completed' } | Sort-Object finishTime | Select-Object -Last 1
|
||||||
|
|
||||||
|
$current = if ($running) { $running.name } elseif ($last) { $last.name } else { '?' }
|
||||||
|
Write-Host "$($b.definition.name) (build $buildId): $($b.status) — etapa atual: $current"
|
||||||
|
}
|
||||||
29
scripts/auto-organized/check_templates.ps1
Normal file
29
scripts/auto-organized/check_templates.ps1
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp'
|
||||||
|
$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p))
|
||||||
|
$h = @{ Authorization = 'Basic ' + $t; 'Content-Type' = 'application/json' }
|
||||||
|
$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis'
|
||||||
|
$repoId = 'ae7542f8-d76e-4a45-b8b2-745e18cd2f26'
|
||||||
|
|
||||||
|
# Listar todos os templates na pasta cd/
|
||||||
|
$tree = Invoke-RestMethod -Uri "$base/git/repositories/$repoId/items?scopePath=/cd`&recursionLevel=OneLevel`&api-version=7.0" -Headers $h
|
||||||
|
Write-Host "=== Templates em /cd ===" -ForegroundColor Cyan
|
||||||
|
$tree.value | Where-Object { $_.gitObjectType -eq 'blob' } | Select-Object -ExpandProperty path
|
||||||
|
|
||||||
|
# Ler os templates OCI mais importantes
|
||||||
|
$cdTemplates = @(
|
||||||
|
'/cd/oci-kubeconfig.yml',
|
||||||
|
'/cd/argocd-apply-app.yml',
|
||||||
|
'/cd/argocd-repo-secret.yml',
|
||||||
|
'/cd/push-ocir-template.yaml',
|
||||||
|
'/ci/push-ocir-template.yaml'
|
||||||
|
)
|
||||||
|
|
||||||
|
foreach ($tmpl in $cdTemplates) {
|
||||||
|
Write-Host "`n=== $tmpl ===" -ForegroundColor Cyan
|
||||||
|
try {
|
||||||
|
$content = Invoke-RestMethod -Uri "$base/git/repositories/$repoId/items?path=$tmpl`&versionDescriptor.version=main`&api-version=7.0" -Headers $h -ErrorAction Stop
|
||||||
|
Write-Host $content
|
||||||
|
} catch {
|
||||||
|
Write-Host " NAO ENCONTRADO" -ForegroundColor Yellow
|
||||||
|
}
|
||||||
|
}
|
||||||
55
scripts/auto-organized/check_vg.ps1
Normal file
55
scripts/auto-organized/check_vg.ps1
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp'
|
||||||
|
$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p))
|
||||||
|
$h = @{ Authorization = 'Basic ' + $t; 'Content-Type' = 'application/json' }
|
||||||
|
$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis'
|
||||||
|
|
||||||
|
# Listar todos os variable groups
|
||||||
|
$vgs = Invoke-RestMethod -Uri "$base/distributedtask/variablegroups?api-version=7.0" -Headers $h
|
||||||
|
Write-Host "=== Variable Groups disponiveis ===" -ForegroundColor Cyan
|
||||||
|
$vgs.value | Select-Object id, name | Format-Table
|
||||||
|
|
||||||
|
# Verificar oci-terraform especificamente
|
||||||
|
$vg = $vgs.value | Where-Object { $_.name -eq 'oci-terraform' }
|
||||||
|
if (-not $vg) {
|
||||||
|
Write-Host "AVISO: VG 'oci-terraform' nao encontrado" -ForegroundColor Yellow
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "=== VG: $($vg.name) (ID: $($vg.id)) ===" -ForegroundColor Cyan
|
||||||
|
Write-Host ""
|
||||||
|
|
||||||
|
# Variaveis necessarias para o deploy dos MSs
|
||||||
|
$required = @(
|
||||||
|
'OKE_CLUSTER_OCID',
|
||||||
|
'OCI_CLUSTER_OCID_OVERRIDE',
|
||||||
|
'OCIR_REGISTRY',
|
||||||
|
'OCIR_NAMESPACE',
|
||||||
|
'OCIR_USERNAME',
|
||||||
|
'OCIR_AUTH_TOKEN',
|
||||||
|
'ARGOCD_REPO_URL',
|
||||||
|
'ARGOCD_REPO_PAT',
|
||||||
|
'OCI_TENANCY_OCID',
|
||||||
|
'OCI_USER_OCID',
|
||||||
|
'OCI_FINGERPRINT',
|
||||||
|
'OCI_PRIVATE_KEY_B64',
|
||||||
|
'OCI_REGION'
|
||||||
|
)
|
||||||
|
|
||||||
|
$vars = $vg.variables.PSObject.Properties
|
||||||
|
|
||||||
|
Write-Host "Variaveis presentes:" -ForegroundColor Green
|
||||||
|
foreach ($v in $vars) {
|
||||||
|
$isSecret = $v.Value.isSecret
|
||||||
|
$val = if ($isSecret) { '(secret)' } else { $v.Value.value }
|
||||||
|
$marker = if ($v.Name -in $required) { '[REQUIRED]' } else { '[extra] ' }
|
||||||
|
Write-Host " $marker $($v.Name) = $val"
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "Variaveis NECESSARIAS ausentes:" -ForegroundColor Red
|
||||||
|
$presentNames = $vars | Select-Object -ExpandProperty Name
|
||||||
|
foreach ($r in $required) {
|
||||||
|
if ($r -notin $presentNames) {
|
||||||
|
Write-Host " FALTANDO: $r" -ForegroundColor Red
|
||||||
|
}
|
||||||
|
}
|
||||||
31
scripts/auto-organized/check_vg2.ps1
Normal file
31
scripts/auto-organized/check_vg2.ps1
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp'
|
||||||
|
$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p))
|
||||||
|
$h = @{ Authorization = 'Basic ' + $t; 'Content-Type' = 'application/json' }
|
||||||
|
$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis'
|
||||||
|
|
||||||
|
$vgs = Invoke-RestMethod -Uri "$base/distributedtask/variablegroups?api-version=7.0" -Headers $h
|
||||||
|
|
||||||
|
# VGs por MS
|
||||||
|
$msNames = @('ms-auth-external','ms-auth-sso','ms-barramento','ms-belt','ms-notify','ms-parameters','ms-person','ms-poc','ms-user')
|
||||||
|
|
||||||
|
Write-Host "=== Variable Groups por MS (dev) ===" -ForegroundColor Cyan
|
||||||
|
foreach ($ms in $msNames) {
|
||||||
|
$vgName = "$ms-dev"
|
||||||
|
$vg = $vgs.value | Where-Object { $_.name -eq $vgName }
|
||||||
|
if (-not $vg) {
|
||||||
|
Write-Host " $vgName : NAO ENCONTRADO" -ForegroundColor Red
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
$vars = $vg.variables.PSObject.Properties | Select-Object -ExpandProperty Name
|
||||||
|
Write-Host " $vgName : $($vars -join ', ')" -ForegroundColor Green
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "=== Verificando ms-auth-external-dev em detalhe ===" -ForegroundColor Cyan
|
||||||
|
$vgDetail = $vgs.value | Where-Object { $_.name -eq 'ms-auth-external-dev' }
|
||||||
|
if ($vgDetail) {
|
||||||
|
$vgDetail.variables.PSObject.Properties | ForEach-Object {
|
||||||
|
$val = if ($_.Value.isSecret) { '(secret)' } else { $_.Value.value }
|
||||||
|
Write-Host " $($_.Name) = $val"
|
||||||
|
}
|
||||||
|
}
|
||||||
46
scripts/auto-organized/complete_pr.ps1
Normal file
46
scripts/auto-organized/complete_pr.ps1
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp'
|
||||||
|
$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p))
|
||||||
|
$h = @{ Authorization = 'Basic ' + $t; 'Content-Type' = 'application/json' }
|
||||||
|
$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis'
|
||||||
|
$baseOrg = 'https://dev.azure.com/CN-Squad/_apis'
|
||||||
|
$repoId = 'ae7542f8-d76e-4a45-b8b2-745e18cd2f26'
|
||||||
|
$prId = 2135
|
||||||
|
|
||||||
|
# Pegar identity do usuario atual
|
||||||
|
$me = Invoke-RestMethod -Uri "https://app.vssps.visualstudio.com/_apis/profile/me?api-version=7.0" -Headers $h
|
||||||
|
Write-Host "Usuario: $($me.displayName) - ID: $($me.id)"
|
||||||
|
|
||||||
|
# Aprovar o PR com o ID correto do usuario
|
||||||
|
Write-Host "Aprovando PR..."
|
||||||
|
$voteBody = @{ vote = 10 } | ConvertTo-Json
|
||||||
|
try {
|
||||||
|
$vote = Invoke-RestMethod -Uri "$base/git/repositories/$repoId/pullrequests/$prId/reviewers/$($me.id)?api-version=7.0" -Method PUT -Headers $h -Body $voteBody -ErrorAction Stop
|
||||||
|
Write-Host " Voto registrado: $($vote.vote)" -ForegroundColor Green
|
||||||
|
} catch {
|
||||||
|
Write-Host " ERRO ao votar: $_" -ForegroundColor Red
|
||||||
|
}
|
||||||
|
|
||||||
|
# Tentar completar com bypassPolicy
|
||||||
|
$featureSha = '7a8a0128350d43d839118383414a1b0dc4f24e44'
|
||||||
|
$completeBody = @{
|
||||||
|
status = 'completed'
|
||||||
|
lastMergeSourceCommit = @{ commitId = $featureSha }
|
||||||
|
completionOptions = @{
|
||||||
|
mergeStrategy = 'squash'
|
||||||
|
deleteSourceBranch = $false
|
||||||
|
bypassPolicy = $true
|
||||||
|
bypassReason = 'Merge automatico - correcao de infra'
|
||||||
|
}
|
||||||
|
} | ConvertTo-Json -Depth 5
|
||||||
|
|
||||||
|
Write-Host "Completando PR #$prId..."
|
||||||
|
try {
|
||||||
|
$result = Invoke-RestMethod -Uri "$base/git/repositories/$repoId/pullrequests/$prId`?api-version=7.0" -Method PATCH -Headers $h -Body $completeBody -ErrorAction Stop
|
||||||
|
Write-Host " Status: $($result.status)" -ForegroundColor Green
|
||||||
|
if ($result.status -eq 'completed') {
|
||||||
|
Write-Host " Merge realizado com sucesso!" -ForegroundColor Green
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
$errMsg = $_.ErrorDetails.Message | ConvertFrom-Json -ErrorAction SilentlyContinue
|
||||||
|
Write-Host " ERRO: $($errMsg.message)" -ForegroundColor Red
|
||||||
|
}
|
||||||
1
scripts/auto-organized/coolify_create_api2.json
Normal file
1
scripts/auto-organized/coolify_create_api2.json
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{"project_uuid":"vs4owwg0g0cwc4w0gwkc4w8s","server_uuid":"m844o4gkwkwcc0k48swgs8c8","environment_uuid":"b0kwogog804ws00k4ko8c080","environment_name":"local","private_key_uuid":"l84oowwskcok00kgg8s48w44","git_repository":"git@forgejo-redbull:administrator/poc-v1.git","git_branch":"master","build_pack":"dockerfile","ports_exposes":"7777","name":"icatu-poc-v1-api2","base_directory":"/","autogenerate_domain":false,"instant_deploy":false}
|
||||||
14
scripts/auto-organized/coolify_create_backend.json
Normal file
14
scripts/auto-organized/coolify_create_backend.json
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"project_uuid": "zsk0ws0gkks08s0kckwgkssc",
|
||||||
|
"server_uuid": "m844o4gkwkwcc0k48swgs8c8",
|
||||||
|
"environment_uuid": "l4ssc4cs88ko44s4wsgk88cc",
|
||||||
|
"private_key_uuid": "l84oowwskcok00kgg8s48w44",
|
||||||
|
"git_repository": "git@github.com:rede5/edu-tenant-manager.git",
|
||||||
|
"git_branch": "dev",
|
||||||
|
"build_pack": "dockerfile",
|
||||||
|
"ports_exposes": "8080",
|
||||||
|
"name": "edu-tenant-backend",
|
||||||
|
"base_directory": "/backend",
|
||||||
|
"autogenerate_domain": false,
|
||||||
|
"instant_deploy": false
|
||||||
|
}
|
||||||
14
scripts/auto-organized/coolify_create_frontend.json
Normal file
14
scripts/auto-organized/coolify_create_frontend.json
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"project_uuid": "zsk0ws0gkks08s0kckwgkssc",
|
||||||
|
"server_uuid": "m844o4gkwkwcc0k48swgs8c8",
|
||||||
|
"environment_uuid": "l4ssc4cs88ko44s4wsgk88cc",
|
||||||
|
"private_key_uuid": "l84oowwskcok00kgg8s48w44",
|
||||||
|
"git_repository": "git@github.com:rede5/edu-tenant-manager.git",
|
||||||
|
"git_branch": "dev",
|
||||||
|
"build_pack": "dockerfile",
|
||||||
|
"ports_exposes": "80",
|
||||||
|
"name": "edu-tenant-frontend",
|
||||||
|
"base_directory": "/frontend",
|
||||||
|
"autogenerate_domain": false,
|
||||||
|
"instant_deploy": false
|
||||||
|
}
|
||||||
1
scripts/auto-organized/coolify_patch_api2_domain.json
Normal file
1
scripts/auto-organized/coolify_patch_api2_domain.json
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{"domains":"https://api-icatu-local.gohorsejobs.com","force_domain_override":true}
|
||||||
3
scripts/auto-organized/coolify_patch_backend.json
Normal file
3
scripts/auto-organized/coolify_patch_backend.json
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"fqdn": "https://api-edutenant.rede5.com.br"
|
||||||
|
}
|
||||||
1
scripts/auto-organized/coolify_patch_db.json
Normal file
1
scripts/auto-organized/coolify_patch_db.json
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{"key":"SQLSERVER_DB","value":"loja_pitbull","is_literal":false,"is_preview":false,"is_multiline":false,"is_shown_once":false}
|
||||||
3
scripts/auto-organized/coolify_patch_frontend.json
Normal file
3
scripts/auto-organized/coolify_patch_frontend.json
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"fqdn": "https://edutenant.rede5.com.br"
|
||||||
|
}
|
||||||
1
scripts/auto-organized/coolify_patch_tmp.json
Normal file
1
scripts/auto-organized/coolify_patch_tmp.json
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{"key":"SQLSERVER_DB_PRD","value":"loja_pitbull","is_literal":false,"is_preview":true,"is_multiline":false,"is_shown_once":false}
|
||||||
28
scripts/auto-organized/create_mfe_shell_deployment.json
Normal file
28
scripts/auto-organized/create_mfe_shell_deployment.json
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
{
|
||||||
|
"routes": [
|
||||||
|
{
|
||||||
|
"path": "/",
|
||||||
|
"methods": ["GET"],
|
||||||
|
"backend": {
|
||||||
|
"type": "HTTP_BACKEND",
|
||||||
|
"url": "https://objectstorage.sa-saopaulo-1.oraclecloud.com/n/grbb7qzeuoag/b/mfe-shell-dev/o/index.html",
|
||||||
|
"connectTimeoutInSeconds": 10,
|
||||||
|
"readTimeoutInSeconds": 30,
|
||||||
|
"sendTimeoutInSeconds": 10,
|
||||||
|
"isSSLVerifyDisabled": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "/{path*}",
|
||||||
|
"methods": ["GET"],
|
||||||
|
"backend": {
|
||||||
|
"type": "HTTP_BACKEND",
|
||||||
|
"url": "https://objectstorage.sa-saopaulo-1.oraclecloud.com/n/grbb7qzeuoag/b/mfe-shell-dev/o/${request.path[path]}",
|
||||||
|
"connectTimeoutInSeconds": 10,
|
||||||
|
"readTimeoutInSeconds": 30,
|
||||||
|
"sendTimeoutInSeconds": 10,
|
||||||
|
"isSSLVerifyDisabled": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
5
scripts/auto-organized/fetch_env.ps1
Normal file
5
scripts/auto-organized/fetch_env.ps1
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp'
|
||||||
|
$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p))
|
||||||
|
$h = @{ Authorization = 'Basic ' + $t }
|
||||||
|
$uri = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis/git/repositories/9f652079-76d7-4415-8c26-e40fdbcb6120/items?path=/src/main.ts&versionDescriptor.version=devops&api-version=7.0'
|
||||||
|
Invoke-RestMethod -Uri $uri -Headers $h
|
||||||
35
scripts/auto-organized/final_status.ps1
Normal file
35
scripts/auto-organized/final_status.ps1
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp'
|
||||||
|
$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p))
|
||||||
|
$h = @{ Authorization = 'Basic ' + $t }
|
||||||
|
$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis'
|
||||||
|
|
||||||
|
foreach ($buildId in @(6181, 6182, 6185, 6186)) {
|
||||||
|
$b = Invoke-RestMethod -Uri "$base/build/builds/$buildId`?api-version=7.0" -Headers $h
|
||||||
|
$tl = Invoke-RestMethod -Uri "$base/build/builds/$buildId/timeline?api-version=7.0" -Headers $h
|
||||||
|
|
||||||
|
$icon = if ($b.result -eq 'succeeded') { 'OK' } else { 'FALHOU' }
|
||||||
|
Write-Host "[$icon] $($b.definition.name) (build $buildId): $($b.result)" -ForegroundColor $(if ($b.result -eq 'succeeded') { 'Green' } else { 'Red' })
|
||||||
|
|
||||||
|
$tl.records | Where-Object { $_.type -eq 'Stage' } |
|
||||||
|
Sort-Object order |
|
||||||
|
ForEach-Object {
|
||||||
|
$icon2 = if ($_.result -eq 'succeeded') { 'v' } elseif ($_.result -eq 'failed') { 'x' } else { '-' }
|
||||||
|
Write-Host " [$icon2] $($_.name): $($_.result)"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Se falhou, mostrar erro
|
||||||
|
if ($b.result -eq 'failed') {
|
||||||
|
if ($b.validationResults) {
|
||||||
|
$b.validationResults | Select-Object -First 1 | ForEach-Object { Write-Host " ERRO: $($_.message)" -ForegroundColor Yellow }
|
||||||
|
} else {
|
||||||
|
$failedTask = $tl.records | Where-Object { $_.result -eq 'failed' -and $_.type -eq 'Task' } | Select-Object -First 1
|
||||||
|
if ($failedTask) {
|
||||||
|
Write-Host " Task falhou: $($failedTask.name)" -ForegroundColor Yellow
|
||||||
|
if ($failedTask.issues) {
|
||||||
|
$failedTask.issues | Select-Object -First 3 | ForEach-Object { Write-Host " $($_.message)" -ForegroundColor Yellow }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Write-Host ""
|
||||||
|
}
|
||||||
35
scripts/auto-organized/final_status2.ps1
Normal file
35
scripts/auto-organized/final_status2.ps1
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp'
|
||||||
|
$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p))
|
||||||
|
$h = @{ Authorization = 'Basic ' + $t }
|
||||||
|
$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis'
|
||||||
|
|
||||||
|
foreach ($buildId in @(6181, 6182, 6185, 6186)) {
|
||||||
|
$b = Invoke-RestMethod -Uri "$base/build/builds/$buildId`?api-version=7.0" -Headers $h
|
||||||
|
$tl = Invoke-RestMethod -Uri "$base/build/builds/$buildId/timeline?api-version=7.0" -Headers $h
|
||||||
|
|
||||||
|
$icon = if ($b.result -eq 'succeeded') { 'OK' } else { 'FALHOU' }
|
||||||
|
Write-Host "[$icon] $($b.definition.name) (build $buildId): $($b.result)" -ForegroundColor $(if ($b.result -eq 'succeeded') { 'Green' } else { 'Red' })
|
||||||
|
|
||||||
|
$tl.records | Where-Object { $_.type -eq 'Stage' } |
|
||||||
|
Sort-Object order |
|
||||||
|
ForEach-Object {
|
||||||
|
$icon2 = if ($_.result -eq 'succeeded') { 'v' } elseif ($_.result -eq 'failed') { 'x' } else { '-' }
|
||||||
|
Write-Host " [$icon2] $($_.name): $($_.result)"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Se falhou, mostrar erro
|
||||||
|
if ($b.result -eq 'failed') {
|
||||||
|
if ($b.validationResults) {
|
||||||
|
$b.validationResults | Select-Object -First 1 | ForEach-Object { Write-Host " ERRO: $($_.message)" -ForegroundColor Yellow }
|
||||||
|
} else {
|
||||||
|
$failedTask = $tl.records | Where-Object { $_.result -eq 'failed' -and $_.type -eq 'Task' } | Select-Object -First 1
|
||||||
|
if ($failedTask) {
|
||||||
|
Write-Host " Task falhou: $($failedTask.name)" -ForegroundColor Yellow
|
||||||
|
if ($failedTask.issues) {
|
||||||
|
$failedTask.issues | Select-Object -First 3 | ForEach-Object { Write-Host " $($_.message)" -ForegroundColor Yellow }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Write-Host ""
|
||||||
|
}
|
||||||
66
scripts/auto-organized/fix_cf_dns_mfe_shell.ps1
Normal file
66
scripts/auto-organized/fix_cf_dns_mfe_shell.ps1
Normal file
|
|
@ -0,0 +1,66 @@
|
||||||
|
$tokenPath = "$env:USERPROFILE\.ssh\cloudflare-token"
|
||||||
|
$CF_TOKEN = (Get-Content $tokenPath -Encoding UTF8 -Raw).Trim()
|
||||||
|
Write-Host "Token len: $($CF_TOKEN.Length) preview: $($CF_TOKEN.Substring(0,4))..."
|
||||||
|
|
||||||
|
$cfh = @{ Authorization = "Bearer $CF_TOKEN"; 'Content-Type' = 'application/json' }
|
||||||
|
|
||||||
|
# Zone ID
|
||||||
|
$zonesResp = Invoke-RestMethod "https://api.cloudflare.com/client/v4/zones?name=invista.com.br&per_page=1" -Headers $cfh
|
||||||
|
if (-not $zonesResp.success) {
|
||||||
|
Write-Host "ERRO ao buscar zone: $($zonesResp.errors | ConvertTo-Json)"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
$zoneId = $zonesResp.result[0].id
|
||||||
|
Write-Host "Zone ID: $zoneId"
|
||||||
|
|
||||||
|
# Buscar record existente para mfe-shell-dev.invista.com.br
|
||||||
|
$name = "mfe-shell-dev.invista.com.br"
|
||||||
|
$resp = Invoke-RestMethod "https://api.cloudflare.com/client/v4/zones/$zoneId/dns_records?name=$name&per_page=10" -Headers $cfh
|
||||||
|
Write-Host "Records existentes para $name :"
|
||||||
|
$resp.result | ForEach-Object {
|
||||||
|
Write-Host " id=$($_.id) type=$($_.type) content=$($_.content) proxied=$($_.proxied)"
|
||||||
|
}
|
||||||
|
|
||||||
|
# IP do FortiGate1 (ponto de entrada público)
|
||||||
|
$fortiIP = "136.248.66.216"
|
||||||
|
|
||||||
|
if ($resp.result.Count -gt 0) {
|
||||||
|
# Atualizar record existente (pegar o primeiro)
|
||||||
|
$recordId = $resp.result[0].id
|
||||||
|
$body = @{
|
||||||
|
type = "A"
|
||||||
|
name = $name
|
||||||
|
content = $fortiIP
|
||||||
|
ttl = 1 # 1 = Auto no Cloudflare
|
||||||
|
proxied = $true
|
||||||
|
} | ConvertTo-Json -Depth 3
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "Atualizando record $recordId para A $fortiIP (proxied)..."
|
||||||
|
$updateResp = Invoke-RestMethod "https://api.cloudflare.com/client/v4/zones/$zoneId/dns_records/$recordId" `
|
||||||
|
-Method PUT -Headers $cfh -Body $body
|
||||||
|
if ($updateResp.success) {
|
||||||
|
Write-Host "OK: $($updateResp.result.type) $($updateResp.result.name) -> $($updateResp.result.content) proxied=$($updateResp.result.proxied)"
|
||||||
|
} else {
|
||||||
|
Write-Host "ERRO: $($updateResp.errors | ConvertTo-Json)"
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
# Criar novo record
|
||||||
|
$body = @{
|
||||||
|
type = "A"
|
||||||
|
name = $name
|
||||||
|
content = $fortiIP
|
||||||
|
ttl = 1
|
||||||
|
proxied = $true
|
||||||
|
} | ConvertTo-Json -Depth 3
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "Criando A record $name -> $fortiIP (proxied)..."
|
||||||
|
$createResp = Invoke-RestMethod "https://api.cloudflare.com/client/v4/zones/$zoneId/dns_records" `
|
||||||
|
-Method POST -Headers $cfh -Body $body
|
||||||
|
if ($createResp.success) {
|
||||||
|
Write-Host "OK: $($createResp.result.type) $($createResp.result.name) -> $($createResp.result.content) proxied=$($createResp.result.proxied)"
|
||||||
|
} else {
|
||||||
|
Write-Host "ERRO: $($createResp.errors | ConvertTo-Json)"
|
||||||
|
}
|
||||||
|
}
|
||||||
44
scripts/auto-organized/fix_cf_dns_mfe_shell_oci.ps1
Normal file
44
scripts/auto-organized/fix_cf_dns_mfe_shell_oci.ps1
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
$email = 'tiago.ribeiro@inventcloud.com.br'
|
||||||
|
$key = '7ae5565ab2dcdfdfdd66efb1105e27d18d186'
|
||||||
|
$h = @{ 'X-Auth-Email' = $email; 'X-Auth-Key' = $key; 'Content-Type' = 'application/json' }
|
||||||
|
|
||||||
|
$zoneName = 'invista.com.br'
|
||||||
|
$recordName = 'mfe-shell-dev-oci.invista.com.br'
|
||||||
|
$gwHostname = 'bjlibdhd5wqhf7p3ua4pgv3zly.apigateway.sa-saopaulo-1.oci.customer-oci.com'
|
||||||
|
|
||||||
|
# Buscar Zone ID
|
||||||
|
$zones = Invoke-RestMethod "https://api.cloudflare.com/client/v4/zones?name=$zoneName" -Headers $h
|
||||||
|
$zoneId = $zones.result[0].id
|
||||||
|
Write-Host "Zone ID: $zoneId"
|
||||||
|
|
||||||
|
# Buscar todos os records existentes para o subdomain
|
||||||
|
$existing = Invoke-RestMethod "https://api.cloudflare.com/client/v4/zones/$zoneId/dns_records?name=$recordName" -Headers $h
|
||||||
|
Write-Host "Records existentes: $($existing.result.Count)"
|
||||||
|
$existing.result | ForEach-Object { Write-Host " $($_.type) $($_.name) -> $($_.content)" }
|
||||||
|
|
||||||
|
# Deletar records existentes (A record → FortiGate)
|
||||||
|
foreach ($rec in $existing.result) {
|
||||||
|
Write-Host "Deletando $($rec.id)..."
|
||||||
|
$del = Invoke-RestMethod "https://api.cloudflare.com/client/v4/zones/$zoneId/dns_records/$($rec.id)" `
|
||||||
|
-Method DELETE -Headers $h
|
||||||
|
Write-Host " Deleted: $($del.success)"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Criar CNAME proxied → OCI API Gateway público
|
||||||
|
$payload = @{
|
||||||
|
type = 'CNAME'
|
||||||
|
name = $recordName
|
||||||
|
content = $gwHostname
|
||||||
|
proxied = $true
|
||||||
|
ttl = 1
|
||||||
|
} | ConvertTo-Json
|
||||||
|
|
||||||
|
$result = Invoke-RestMethod "https://api.cloudflare.com/client/v4/zones/$zoneId/dns_records" `
|
||||||
|
-Method POST -Headers $h -Body $payload
|
||||||
|
|
||||||
|
if ($result.success) {
|
||||||
|
Write-Host "DNS criado: $recordName -> $gwHostname (CNAME proxied)"
|
||||||
|
} else {
|
||||||
|
Write-Host "ERRO:"
|
||||||
|
$result | ConvertTo-Json | Write-Host
|
||||||
|
}
|
||||||
117
scripts/auto-organized/fix_mfe_pipelines_oci.ps1
Normal file
117
scripts/auto-organized/fix_mfe_pipelines_oci.ps1
Normal file
|
|
@ -0,0 +1,117 @@
|
||||||
|
# fix_mfe_pipelines_oci.ps1
|
||||||
|
# Atualiza azure-pipelines.yml na branch devops de cada MFE repo para usar
|
||||||
|
# o novo template deploy-mfe-oci.yaml (OCI Object Storage).
|
||||||
|
#
|
||||||
|
# Uso: ./fix_mfe_pipelines_oci.ps1
|
||||||
|
# Requer: PAT com permissao Code (Read & Write) no Azure DevOps
|
||||||
|
|
||||||
|
$pat = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp'
|
||||||
|
$tok = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $pat))
|
||||||
|
$h = @{ Authorization = 'Basic ' + $tok; 'Content-Type' = 'application/json' }
|
||||||
|
$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis'
|
||||||
|
|
||||||
|
# Configuracao dos MFEs: nome do repo -> parametros do template
|
||||||
|
$mfe_config = [ordered]@{
|
||||||
|
'mfe-shell' = @{ mfeName = 'mfe-shell'; isShell = $true }
|
||||||
|
'mfe-auth' = @{ mfeName = 'mfe-auth'; isShell = $false }
|
||||||
|
'mfe-user' = @{ mfeName = 'mfe-user'; isShell = $false }
|
||||||
|
'mfe-person' = @{ mfeName = 'mfe-person'; isShell = $false }
|
||||||
|
'mfe-poc' = @{ mfeName = 'mfe-poc'; isShell = $false }
|
||||||
|
}
|
||||||
|
|
||||||
|
# Buscar todos os repos do projeto
|
||||||
|
Write-Host "Buscando repositorios..." -ForegroundColor Cyan
|
||||||
|
$repos = Invoke-RestMethod -Uri "$base/git/repositories?api-version=7.0" -Headers $h
|
||||||
|
$repo_map = @{}
|
||||||
|
foreach ($r in $repos.value) {
|
||||||
|
$repo_map[$r.name] = $r.id
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($mfe_name in $mfe_config.Keys) {
|
||||||
|
$cfg = $mfe_config[$mfe_name]
|
||||||
|
$repoId = $repo_map[$mfe_name]
|
||||||
|
$isShell = if ($cfg.isShell) { 'true' } else { 'false' }
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "=== $mfe_name ===" -ForegroundColor Cyan
|
||||||
|
|
||||||
|
if (-not $repoId) {
|
||||||
|
Write-Host " AVISO: repo '$mfe_name' nao encontrado no Azure DevOps. Pulando." -ForegroundColor Yellow
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
Write-Host " Repo ID: $repoId"
|
||||||
|
|
||||||
|
# 1. Verificar se branch devops existe
|
||||||
|
$ref = Invoke-RestMethod -Uri "$base/git/repositories/$repoId/refs?filter=heads/devops&api-version=7.0" -Headers $h
|
||||||
|
if ($ref.count -eq 0) {
|
||||||
|
Write-Host " AVISO: branch devops nao encontrada. Pulando." -ForegroundColor Yellow
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
$oldSha = $ref.value[0].objectId
|
||||||
|
Write-Host " SHA devops: $oldSha"
|
||||||
|
|
||||||
|
# 2. Verificar se azure-pipelines.yml existe na branch devops
|
||||||
|
$fileExists = $true
|
||||||
|
try {
|
||||||
|
$current = Invoke-RestMethod `
|
||||||
|
-Uri "$base/git/repositories/$repoId/items?path=/azure-pipelines.yml&versionDescriptor.version=devops&api-version=7.0" `
|
||||||
|
-Headers $h -ErrorAction Stop
|
||||||
|
} catch {
|
||||||
|
$fileExists = $false
|
||||||
|
Write-Host " azure-pipelines.yml nao existe na branch devops (sera criado)."
|
||||||
|
}
|
||||||
|
|
||||||
|
# 3. Montar novo conteudo do pipeline
|
||||||
|
$newContent = @"
|
||||||
|
trigger:
|
||||||
|
branches:
|
||||||
|
include:
|
||||||
|
- devops
|
||||||
|
|
||||||
|
resources:
|
||||||
|
repositories:
|
||||||
|
- repository: templates
|
||||||
|
type: git
|
||||||
|
name: azure-pipelines-templates
|
||||||
|
ref: refs/heads/main
|
||||||
|
|
||||||
|
extends:
|
||||||
|
template: mfe/deploy-mfe-oci.yaml@templates
|
||||||
|
parameters:
|
||||||
|
mfeName: '$($cfg.mfeName)'
|
||||||
|
envName: 'dev'
|
||||||
|
isShell: $isShell
|
||||||
|
"@
|
||||||
|
|
||||||
|
# 4. Nao atualizar se conteudo identico
|
||||||
|
if ($fileExists -and $current -eq $newContent) {
|
||||||
|
Write-Host " Sem alteracoes necessarias." -ForegroundColor Yellow
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
# 5. Push para branch devops
|
||||||
|
$changeType = if ($fileExists) { 'edit' } else { 'add' }
|
||||||
|
$body = @{
|
||||||
|
refUpdates = @(@{ name = 'refs/heads/devops'; oldObjectId = $oldSha })
|
||||||
|
commits = @(@{
|
||||||
|
comment = "feat(pipeline): migrar $mfe_name para deploy OCI Object Storage via template"
|
||||||
|
changes = @(@{
|
||||||
|
changeType = $changeType
|
||||||
|
item = @{ path = '/azure-pipelines.yml' }
|
||||||
|
newContent = @{ content = $newContent; contentType = 'rawtext' }
|
||||||
|
})
|
||||||
|
})
|
||||||
|
} | ConvertTo-Json -Depth 10
|
||||||
|
|
||||||
|
try {
|
||||||
|
$result = Invoke-RestMethod `
|
||||||
|
-Uri "$base/git/repositories/$repoId/pushes?api-version=7.0" `
|
||||||
|
-Method POST -Headers $h -Body $body -ErrorAction Stop
|
||||||
|
Write-Host " OK - commit: $($result.commits[0].commitId)" -ForegroundColor Green
|
||||||
|
} catch {
|
||||||
|
Write-Host " ERRO ao fazer push: $_" -ForegroundColor Red
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "Concluido." -ForegroundColor Green
|
||||||
81
scripts/auto-organized/fix_ms_pipelines.ps1
Normal file
81
scripts/auto-organized/fix_ms_pipelines.ps1
Normal file
|
|
@ -0,0 +1,81 @@
|
||||||
|
$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp'
|
||||||
|
$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p))
|
||||||
|
$h = @{ Authorization = 'Basic ' + $t; 'Content-Type' = 'application/json' }
|
||||||
|
$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis'
|
||||||
|
|
||||||
|
$ms_repos = @{
|
||||||
|
'ms-auth-external' = '976a0237-6006-4dae-a084-f054c815d601'
|
||||||
|
'ms-auth-sso' = '9932e1e0-48ab-417a-b712-36e3b618d758'
|
||||||
|
'ms-barramento' = 'ce4eff9f-0d40-4e27-b210-8c18b87d03f0'
|
||||||
|
'ms-belt' = 'f6223ed1-ab1e-47f9-8ec9-e0ca05c8feac'
|
||||||
|
'ms-notify' = '76c0279c-55d7-4001-97ed-8d279f7baa07'
|
||||||
|
'ms-parameters' = '4de79bf2-403b-4e60-ba36-87449ccbdc34'
|
||||||
|
'ms-person' = '58f9c27e-9f46-4e4c-b1fb-1b2ff63e021b'
|
||||||
|
'ms-poc' = '7e85222f-c166-4d52-8d37-3cf6ebeaeefa'
|
||||||
|
'ms-user' = '24bdf218-522a-45e2-8a31-96db3962997d'
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($name in $ms_repos.Keys | Sort-Object) {
|
||||||
|
$id = $ms_repos[$name]
|
||||||
|
Write-Host "=== $name ===" -ForegroundColor Cyan
|
||||||
|
|
||||||
|
# 1. Pegar commit atual do branch devops
|
||||||
|
try {
|
||||||
|
$ref = Invoke-RestMethod -Uri "$base/git/repositories/$id/refs?filter=heads/devops&api-version=7.0" -Headers $h -ErrorAction Stop
|
||||||
|
$oldSha = $ref.value[0].objectId
|
||||||
|
Write-Host " SHA devops: $oldSha"
|
||||||
|
} catch {
|
||||||
|
Write-Host " ERRO: nao consegui pegar SHA do devops" -ForegroundColor Red
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
# 2. Pegar conteudo atual do pipeline
|
||||||
|
try {
|
||||||
|
$current = Invoke-RestMethod -Uri "$base/git/repositories/$id/items?path=/azure-pipelines.yaml&versionDescriptor.version=devops&api-version=7.0" -Headers $h -ErrorAction Stop
|
||||||
|
} catch {
|
||||||
|
Write-Host " ERRO: nao encontrei azure-pipelines.yaml" -ForegroundColor Red
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
# 3. Aplicar as correcoes
|
||||||
|
$newContent = $current
|
||||||
|
|
||||||
|
# P1: Corrige template branch feature/cd-deploy-oci-oke -> main
|
||||||
|
$newContent = $newContent -replace 'refs/heads/feature/cd-deploy-oci-oke', 'refs/heads/main'
|
||||||
|
|
||||||
|
# P2: ms-barramento especifico - corrige trigger e default
|
||||||
|
if ($name -eq 'ms-barramento') {
|
||||||
|
# Corrige condition de deploy: 'develop' -> 'devops'
|
||||||
|
$newContent = $newContent -replace "eq\(variables\['Build\.SourceBranchName'\], 'develop'\)", "eq(variables['Build.SourceBranchName'], 'devops')"
|
||||||
|
# Corrige default deployTarget: aws -> oci-argocd
|
||||||
|
$newContent = $newContent -replace "default: aws`n values: \[aws, oci-argocd\]", "default: oci-argocd`n values: [aws, oci-argocd]"
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($newContent -eq $current) {
|
||||||
|
Write-Host " Sem alteracoes necessarias." -ForegroundColor Yellow
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
# 4. Fazer push com o conteudo atualizado
|
||||||
|
$contentBytes = [System.Text.Encoding]::UTF8.GetBytes($newContent)
|
||||||
|
$contentB64 = [Convert]::ToBase64String($contentBytes)
|
||||||
|
|
||||||
|
$body = @{
|
||||||
|
refUpdates = @(@{ name = 'refs/heads/devops'; oldObjectId = $oldSha })
|
||||||
|
commits = @(@{
|
||||||
|
comment = "fix(pipeline): atualiza template ref para main e corrige deploy target OCI"
|
||||||
|
changes = @(@{
|
||||||
|
changeType = 'edit'
|
||||||
|
item = @{ path = '/azure-pipelines.yaml' }
|
||||||
|
newContent = @{ content = $newContent; contentType = 'rawtext' }
|
||||||
|
})
|
||||||
|
})
|
||||||
|
} | ConvertTo-Json -Depth 10
|
||||||
|
|
||||||
|
try {
|
||||||
|
$result = Invoke-RestMethod -Uri "$base/git/repositories/$id/pushes?api-version=7.0" -Method POST -Headers $h -Body $body -ErrorAction Stop
|
||||||
|
Write-Host " OK - commit: $($result.commits[0].commitId)" -ForegroundColor Green
|
||||||
|
} catch {
|
||||||
|
Write-Host " ERRO ao fazer push: $_" -ForegroundColor Red
|
||||||
|
}
|
||||||
|
}
|
||||||
74
scripts/auto-organized/fix_vg.ps1
Normal file
74
scripts/auto-organized/fix_vg.ps1
Normal file
|
|
@ -0,0 +1,74 @@
|
||||||
|
$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp'
|
||||||
|
$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p))
|
||||||
|
$h = @{ Authorization = 'Basic ' + $t; 'Content-Type' = 'application/json' }
|
||||||
|
$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis'
|
||||||
|
|
||||||
|
$vgs = Invoke-RestMethod -Uri "$base/distributedtask/variablegroups?api-version=7.0" -Headers $h
|
||||||
|
|
||||||
|
# =====================================================================
|
||||||
|
# 1. Remover OCIR_REPOSITORY_NAME do VG oci-terraform (ID 34)
|
||||||
|
# =====================================================================
|
||||||
|
Write-Host "=== 1. Removendo OCIR_REPOSITORY_NAME do oci-terraform ===" -ForegroundColor Cyan
|
||||||
|
|
||||||
|
$vg = $vgs.value | Where-Object { $_.name -eq 'oci-terraform' }
|
||||||
|
$vgId = $vg.id
|
||||||
|
|
||||||
|
# Reconstruir o objeto de variaveis sem OCIR_REPOSITORY_NAME
|
||||||
|
$newVars = @{}
|
||||||
|
$vg.variables.PSObject.Properties | Where-Object { $_.Name -ne 'OCIR_REPOSITORY_NAME' } | ForEach-Object {
|
||||||
|
$newVars[$_.Name] = $_.Value
|
||||||
|
}
|
||||||
|
|
||||||
|
$updateBody = @{
|
||||||
|
id = $vgId
|
||||||
|
name = $vg.name
|
||||||
|
type = $vg.type
|
||||||
|
variables = $newVars
|
||||||
|
description = $vg.description
|
||||||
|
} | ConvertTo-Json -Depth 10
|
||||||
|
|
||||||
|
try {
|
||||||
|
$result = Invoke-RestMethod -Uri "$base/distributedtask/variablegroups/$vgId`?api-version=7.0" -Method PUT -Headers $h -Body $updateBody -ErrorAction Stop
|
||||||
|
$stillHas = $result.variables.PSObject.Properties | Where-Object { $_.Name -eq 'OCIR_REPOSITORY_NAME' }
|
||||||
|
if ($stillHas) {
|
||||||
|
Write-Host " AVISO: variavel ainda presente apos update" -ForegroundColor Yellow
|
||||||
|
} else {
|
||||||
|
Write-Host " OK - OCIR_REPOSITORY_NAME removido" -ForegroundColor Green
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
Write-Host " ERRO: $_" -ForegroundColor Red
|
||||||
|
}
|
||||||
|
|
||||||
|
# =====================================================================
|
||||||
|
# 2. Criar VG ms-parameters-dev (ID 34 nao existe, criar novo)
|
||||||
|
# =====================================================================
|
||||||
|
Write-Host "`n=== 2. Criando VG ms-parameters-dev ===" -ForegroundColor Cyan
|
||||||
|
|
||||||
|
$existingMsParams = $vgs.value | Where-Object { $_.name -eq 'ms-parameters-dev' }
|
||||||
|
if ($existingMsParams) {
|
||||||
|
Write-Host " VG ms-parameters-dev ja existe (ID: $($existingMsParams.id))" -ForegroundColor Yellow
|
||||||
|
} else {
|
||||||
|
# Pegar ms-notify-dev como modelo de estrutura
|
||||||
|
$modelo = $vgs.value | Where-Object { $_.name -eq 'ms-notify-dev' }
|
||||||
|
|
||||||
|
$newVgBody = @{
|
||||||
|
name = 'ms-parameters-dev'
|
||||||
|
type = 'Vsts'
|
||||||
|
variables = @{
|
||||||
|
CLUSTER_NAME = @{ value = 'NexusCluster'; isSecret = $false }
|
||||||
|
LOG_GROUP_NAME = @{ value = '/ecs/logs'; isSecret = $false }
|
||||||
|
TASK_CONTAINER_NAME = @{ value = 'ms-parameters'; isSecret = $false }
|
||||||
|
TASK_FAMILY = @{ value = 'ms-parameters'; isSecret = $false }
|
||||||
|
TASK_EXECUTION_ROLE_ARN = @{ value = ''; isSecret = $true }
|
||||||
|
TASK_ROLE_ARN = @{ value = ''; isSecret = $true }
|
||||||
|
LAST_SWAGGER_HASH = @{ value = ''; isSecret = $false }
|
||||||
|
}
|
||||||
|
} | ConvertTo-Json -Depth 5
|
||||||
|
|
||||||
|
try {
|
||||||
|
$created = Invoke-RestMethod -Uri "$base/distributedtask/variablegroups?api-version=7.0" -Method POST -Headers $h -Body $newVgBody -ErrorAction Stop
|
||||||
|
Write-Host " OK - VG criado: $($created.name) (ID: $($created.id))" -ForegroundColor Green
|
||||||
|
} catch {
|
||||||
|
Write-Host " ERRO: $_" -ForegroundColor Red
|
||||||
|
}
|
||||||
|
}
|
||||||
79
scripts/auto-organized/fix_vg2.ps1
Normal file
79
scripts/auto-organized/fix_vg2.ps1
Normal file
|
|
@ -0,0 +1,79 @@
|
||||||
|
$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp'
|
||||||
|
$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p))
|
||||||
|
$h = @{ Authorization = 'Basic ' + $t; 'Content-Type' = 'application/json' }
|
||||||
|
$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis'
|
||||||
|
|
||||||
|
$vgs = Invoke-RestMethod -Uri "$base/distributedtask/variablegroups?api-version=7.0" -Headers $h
|
||||||
|
$vg = $vgs.value | Where-Object { $_.name -eq 'oci-terraform' }
|
||||||
|
$vgId = $vg.id
|
||||||
|
|
||||||
|
# Ver projectReferences do VG existente
|
||||||
|
Write-Host "projectReferences:"
|
||||||
|
$vg.projectReferences | ConvertTo-Json -Depth 5
|
||||||
|
|
||||||
|
# =====================================================================
|
||||||
|
# 1. Remover OCIR_REPOSITORY_NAME do VG oci-terraform
|
||||||
|
# =====================================================================
|
||||||
|
Write-Host "`n=== Removendo OCIR_REPOSITORY_NAME do oci-terraform ===" -ForegroundColor Cyan
|
||||||
|
|
||||||
|
$newVars = @{}
|
||||||
|
$vg.variables.PSObject.Properties | Where-Object { $_.Name -ne 'OCIR_REPOSITORY_NAME' } | ForEach-Object {
|
||||||
|
$newVars[$_.Name] = $_.Value
|
||||||
|
}
|
||||||
|
|
||||||
|
$updateBody = @{
|
||||||
|
id = $vgId
|
||||||
|
name = $vg.name
|
||||||
|
type = $vg.type
|
||||||
|
variables = $newVars
|
||||||
|
description = $vg.description
|
||||||
|
projectReferences = $vg.projectReferences
|
||||||
|
} | ConvertTo-Json -Depth 10
|
||||||
|
|
||||||
|
try {
|
||||||
|
$result = Invoke-RestMethod -Uri "$base/distributedtask/variablegroups/$vgId`?api-version=7.0" -Method PUT -Headers $h -Body $updateBody -ErrorAction Stop
|
||||||
|
$stillHas = $result.variables.PSObject.Properties | Where-Object { $_.Name -eq 'OCIR_REPOSITORY_NAME' }
|
||||||
|
if ($stillHas) {
|
||||||
|
Write-Host " AVISO: variavel ainda presente" -ForegroundColor Yellow
|
||||||
|
} else {
|
||||||
|
Write-Host " OK - OCIR_REPOSITORY_NAME removido" -ForegroundColor Green
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
Write-Host " ERRO: $_" -ForegroundColor Red
|
||||||
|
}
|
||||||
|
|
||||||
|
# =====================================================================
|
||||||
|
# 2. Criar VG ms-parameters-dev
|
||||||
|
# =====================================================================
|
||||||
|
Write-Host "`n=== Criando VG ms-parameters-dev ===" -ForegroundColor Cyan
|
||||||
|
|
||||||
|
$existingMsParams = $vgs.value | Where-Object { $_.name -eq 'ms-parameters-dev' }
|
||||||
|
if ($existingMsParams) {
|
||||||
|
Write-Host " Ja existe (ID: $($existingMsParams.id))" -ForegroundColor Yellow
|
||||||
|
} else {
|
||||||
|
# Usar o mesmo projectReferences do VG modelo
|
||||||
|
$modelo = $vgs.value | Where-Object { $_.name -eq 'ms-notify-dev' }
|
||||||
|
$modeloFull = Invoke-RestMethod -Uri "$base/distributedtask/variablegroups/$($modelo.id)`?api-version=7.0" -Headers $h
|
||||||
|
|
||||||
|
$newVgBody = @{
|
||||||
|
name = 'ms-parameters-dev'
|
||||||
|
type = 'Vsts'
|
||||||
|
variables = @{
|
||||||
|
CLUSTER_NAME = @{ value = 'NexusCluster'; isSecret = $false }
|
||||||
|
LOG_GROUP_NAME = @{ value = '/ecs/logs'; isSecret = $false }
|
||||||
|
TASK_CONTAINER_NAME = @{ value = 'ms-parameters'; isSecret = $false }
|
||||||
|
TASK_FAMILY = @{ value = 'ms-parameters'; isSecret = $false }
|
||||||
|
TASK_EXECUTION_ROLE_ARN = @{ value = ''; isSecret = $true }
|
||||||
|
TASK_ROLE_ARN = @{ value = ''; isSecret = $true }
|
||||||
|
LAST_SWAGGER_HASH = @{ value = ''; isSecret = $false }
|
||||||
|
}
|
||||||
|
projectReferences = $modeloFull.projectReferences
|
||||||
|
} | ConvertTo-Json -Depth 5
|
||||||
|
|
||||||
|
try {
|
||||||
|
$created = Invoke-RestMethod -Uri "$base/distributedtask/variablegroups?api-version=7.0" -Method POST -Headers $h -Body $newVgBody -ErrorAction Stop
|
||||||
|
Write-Host " OK - criado: $($created.name) (ID: $($created.id))" -ForegroundColor Green
|
||||||
|
} catch {
|
||||||
|
Write-Host " ERRO: $_" -ForegroundColor Red
|
||||||
|
}
|
||||||
|
}
|
||||||
91
scripts/auto-organized/fix_vg3.ps1
Normal file
91
scripts/auto-organized/fix_vg3.ps1
Normal file
|
|
@ -0,0 +1,91 @@
|
||||||
|
$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp'
|
||||||
|
$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p))
|
||||||
|
$h = @{ Authorization = 'Basic ' + $t; 'Content-Type' = 'application/json' }
|
||||||
|
$baseOrg = 'https://dev.azure.com/CN-Squad/_apis'
|
||||||
|
$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis'
|
||||||
|
|
||||||
|
# Pegar o ID do projeto
|
||||||
|
$proj = Invoke-RestMethod -Uri "$baseOrg/projects/Invista%20FIDC%20-%20Nexus?api-version=7.0" -Headers $h
|
||||||
|
Write-Host "Projeto: $($proj.name) | ID: $($proj.id)"
|
||||||
|
|
||||||
|
$projectRef = @(
|
||||||
|
@{
|
||||||
|
projectReference = @{ id = $proj.id; name = $proj.name }
|
||||||
|
name = 'oci-terraform'
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
$vgs = Invoke-RestMethod -Uri "$base/distributedtask/variablegroups?api-version=7.0" -Headers $h
|
||||||
|
$vg = $vgs.value | Where-Object { $_.name -eq 'oci-terraform' }
|
||||||
|
$vgId = $vg.id
|
||||||
|
|
||||||
|
# =====================================================================
|
||||||
|
# 1. Remover OCIR_REPOSITORY_NAME do VG oci-terraform
|
||||||
|
# =====================================================================
|
||||||
|
Write-Host "`n=== 1. Removendo OCIR_REPOSITORY_NAME do oci-terraform ===" -ForegroundColor Cyan
|
||||||
|
|
||||||
|
$newVars = @{}
|
||||||
|
$vg.variables.PSObject.Properties | Where-Object { $_.Name -ne 'OCIR_REPOSITORY_NAME' } | ForEach-Object {
|
||||||
|
$newVars[$_.Name] = $_.Value
|
||||||
|
}
|
||||||
|
|
||||||
|
$updateBody = @{
|
||||||
|
id = $vgId
|
||||||
|
name = $vg.name
|
||||||
|
type = $vg.type
|
||||||
|
variables = $newVars
|
||||||
|
description = $vg.description
|
||||||
|
projectReferences = $projectRef
|
||||||
|
} | ConvertTo-Json -Depth 10
|
||||||
|
|
||||||
|
try {
|
||||||
|
$result = Invoke-RestMethod -Uri "$base/distributedtask/variablegroups/$vgId`?api-version=7.0" -Method PUT -Headers $h -Body $updateBody -ErrorAction Stop
|
||||||
|
$stillHas = $result.variables.PSObject.Properties | Where-Object { $_.Name -eq 'OCIR_REPOSITORY_NAME' }
|
||||||
|
if ($stillHas) {
|
||||||
|
Write-Host " AVISO: variavel ainda presente" -ForegroundColor Yellow
|
||||||
|
} else {
|
||||||
|
Write-Host " OK - OCIR_REPOSITORY_NAME removido" -ForegroundColor Green
|
||||||
|
Write-Host " Variaveis restantes: $($result.variables.PSObject.Properties.Name -join ', ')"
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
Write-Host " ERRO: $_" -ForegroundColor Red
|
||||||
|
}
|
||||||
|
|
||||||
|
# =====================================================================
|
||||||
|
# 2. Criar VG ms-parameters-dev
|
||||||
|
# =====================================================================
|
||||||
|
Write-Host "`n=== 2. Criando VG ms-parameters-dev ===" -ForegroundColor Cyan
|
||||||
|
|
||||||
|
$existingMsParams = $vgs.value | Where-Object { $_.name -eq 'ms-parameters-dev' }
|
||||||
|
if ($existingMsParams) {
|
||||||
|
Write-Host " Ja existe (ID: $($existingMsParams.id))" -ForegroundColor Yellow
|
||||||
|
} else {
|
||||||
|
$msParamsRef = @(
|
||||||
|
@{
|
||||||
|
projectReference = @{ id = $proj.id; name = $proj.name }
|
||||||
|
name = 'ms-parameters-dev'
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
$newVgBody = @{
|
||||||
|
name = 'ms-parameters-dev'
|
||||||
|
type = 'Vsts'
|
||||||
|
variables = @{
|
||||||
|
CLUSTER_NAME = @{ value = 'NexusCluster'; isSecret = $false }
|
||||||
|
LOG_GROUP_NAME = @{ value = '/ecs/logs'; isSecret = $false }
|
||||||
|
TASK_CONTAINER_NAME = @{ value = 'ms-parameters'; isSecret = $false }
|
||||||
|
TASK_FAMILY = @{ value = 'ms-parameters'; isSecret = $false }
|
||||||
|
TASK_EXECUTION_ROLE_ARN = @{ value = ''; isSecret = $true }
|
||||||
|
TASK_ROLE_ARN = @{ value = ''; isSecret = $true }
|
||||||
|
LAST_SWAGGER_HASH = @{ value = ''; isSecret = $false }
|
||||||
|
}
|
||||||
|
projectReferences = $msParamsRef
|
||||||
|
} | ConvertTo-Json -Depth 5
|
||||||
|
|
||||||
|
try {
|
||||||
|
$created = Invoke-RestMethod -Uri "$base/distributedtask/variablegroups?api-version=7.0" -Method POST -Headers $h -Body $newVgBody -ErrorAction Stop
|
||||||
|
Write-Host " OK - criado: $($created.name) (ID: $($created.id))" -ForegroundColor Green
|
||||||
|
} catch {
|
||||||
|
Write-Host " ERRO: $_" -ForegroundColor Red
|
||||||
|
}
|
||||||
|
}
|
||||||
80
scripts/auto-organized/fix_vg4.ps1
Normal file
80
scripts/auto-organized/fix_vg4.ps1
Normal file
|
|
@ -0,0 +1,80 @@
|
||||||
|
$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp'
|
||||||
|
$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p))
|
||||||
|
$h = @{ Authorization = 'Basic ' + $t; 'Content-Type' = 'application/json' }
|
||||||
|
$baseOrg = 'https://dev.azure.com/CN-Squad/_apis'
|
||||||
|
$projectId = '28c26924-b0a7-485d-b8c2-c86e48377e85'
|
||||||
|
$vgId = 34
|
||||||
|
|
||||||
|
# Ler VG atual completo
|
||||||
|
$wc = New-Object System.Net.WebClient
|
||||||
|
$wc.Headers['Authorization'] = 'Basic ' + $t
|
||||||
|
$raw = $wc.DownloadString("$baseOrg/distributedtask/variablegroups/$vgId`?api-version=7.0")
|
||||||
|
$vg = $raw | ConvertFrom-Json
|
||||||
|
|
||||||
|
# =====================================================================
|
||||||
|
# 1. Remover OCIR_REPOSITORY_NAME via PUT no endpoint de organizacao
|
||||||
|
# =====================================================================
|
||||||
|
Write-Host "=== 1. Removendo OCIR_REPOSITORY_NAME do oci-terraform ===" -ForegroundColor Cyan
|
||||||
|
|
||||||
|
$newVars = @{}
|
||||||
|
$vg.variables.PSObject.Properties | Where-Object { $_.Name -ne 'OCIR_REPOSITORY_NAME' } | ForEach-Object {
|
||||||
|
$newVars[$_.Name] = $_.Value
|
||||||
|
}
|
||||||
|
|
||||||
|
$updateBody = @{
|
||||||
|
id = $vg.id
|
||||||
|
name = $vg.name
|
||||||
|
type = $vg.type
|
||||||
|
variables = $newVars
|
||||||
|
description = $vg.description
|
||||||
|
} | ConvertTo-Json -Depth 10
|
||||||
|
|
||||||
|
$url = "$baseOrg/distributedtask/variablegroups/$vgId`?projectIds=$projectId`&api-version=7.0"
|
||||||
|
try {
|
||||||
|
$hWithCT = @{ Authorization = 'Basic ' + $t; 'Content-Type' = 'application/json' }
|
||||||
|
$result = Invoke-RestMethod -Uri $url -Method PUT -Headers $hWithCT -Body $updateBody -ErrorAction Stop
|
||||||
|
$stillHas = $result.variables.PSObject.Properties | Where-Object { $_.Name -eq 'OCIR_REPOSITORY_NAME' }
|
||||||
|
if ($stillHas) {
|
||||||
|
Write-Host " AVISO: variavel ainda presente" -ForegroundColor Yellow
|
||||||
|
} else {
|
||||||
|
Write-Host " OK - OCIR_REPOSITORY_NAME removido" -ForegroundColor Green
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
$errMsg = $_.ErrorDetails.Message | ConvertFrom-Json -ErrorAction SilentlyContinue
|
||||||
|
Write-Host " ERRO: $($errMsg.message)" -ForegroundColor Red
|
||||||
|
}
|
||||||
|
|
||||||
|
# =====================================================================
|
||||||
|
# 2. Criar VG ms-parameters-dev via endpoint de organizacao
|
||||||
|
# =====================================================================
|
||||||
|
Write-Host "`n=== 2. Criando VG ms-parameters-dev ===" -ForegroundColor Cyan
|
||||||
|
|
||||||
|
# Verificar se ja existe
|
||||||
|
$allVgs = Invoke-RestMethod -Uri "$baseOrg/distributedtask/variablegroups?api-version=7.0" -Headers $h
|
||||||
|
$existing = $allVgs.value | Where-Object { $_.name -eq 'ms-parameters-dev' }
|
||||||
|
if ($existing) {
|
||||||
|
Write-Host " Ja existe (ID: $($existing.id))" -ForegroundColor Yellow
|
||||||
|
} else {
|
||||||
|
$newVgBody = @{
|
||||||
|
name = 'ms-parameters-dev'
|
||||||
|
type = 'Vsts'
|
||||||
|
variables = @{
|
||||||
|
CLUSTER_NAME = @{ value = 'NexusCluster'; isSecret = $false }
|
||||||
|
LOG_GROUP_NAME = @{ value = '/ecs/logs'; isSecret = $false }
|
||||||
|
TASK_CONTAINER_NAME = @{ value = 'ms-parameters'; isSecret = $false }
|
||||||
|
TASK_FAMILY = @{ value = 'ms-parameters'; isSecret = $false }
|
||||||
|
TASK_EXECUTION_ROLE_ARN = @{ value = ''; isSecret = $true }
|
||||||
|
TASK_ROLE_ARN = @{ value = ''; isSecret = $true }
|
||||||
|
LAST_SWAGGER_HASH = @{ value = ''; isSecret = $false }
|
||||||
|
}
|
||||||
|
} | ConvertTo-Json -Depth 5
|
||||||
|
|
||||||
|
$createUrl = "$baseOrg/distributedtask/variablegroups?projectIds=$projectId`&api-version=7.0"
|
||||||
|
try {
|
||||||
|
$created = Invoke-RestMethod -Uri $createUrl -Method POST -Headers $h -Body $newVgBody -ErrorAction Stop
|
||||||
|
Write-Host " OK - criado: $($created.name) (ID: $($created.id))" -ForegroundColor Green
|
||||||
|
} catch {
|
||||||
|
$errMsg = $_.ErrorDetails.Message | ConvertFrom-Json -ErrorAction SilentlyContinue
|
||||||
|
Write-Host " ERRO: $($errMsg.message)" -ForegroundColor Red
|
||||||
|
}
|
||||||
|
}
|
||||||
95
scripts/auto-organized/fix_vg5.ps1
Normal file
95
scripts/auto-organized/fix_vg5.ps1
Normal file
|
|
@ -0,0 +1,95 @@
|
||||||
|
$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp'
|
||||||
|
$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p))
|
||||||
|
$h = @{ Authorization = 'Basic ' + $t; 'Content-Type' = 'application/json' }
|
||||||
|
$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis'
|
||||||
|
$projectId = '28c26924-b0a7-485d-b8c2-c86e48377e85'
|
||||||
|
$vgId = 34
|
||||||
|
|
||||||
|
# Ler VG atual como string raw
|
||||||
|
$wc = New-Object System.Net.WebClient
|
||||||
|
$wc.Headers['Authorization'] = 'Basic ' + $t
|
||||||
|
$raw = $wc.DownloadString("$base/distributedtask/variablegroups/$vgId`?api-version=7.0")
|
||||||
|
|
||||||
|
# Usar .NET JSON para remover a chave
|
||||||
|
Add-Type -AssemblyName System.Web.Extensions
|
||||||
|
$serializer = New-Object System.Web.Script.Serialization.JavaScriptSerializer
|
||||||
|
$serializer.MaxJsonLength = 10000000
|
||||||
|
|
||||||
|
$obj = $serializer.DeserializeObject($raw)
|
||||||
|
|
||||||
|
# Remover OCIR_REPOSITORY_NAME das variaveis
|
||||||
|
if ($obj['variables'].ContainsKey('OCIR_REPOSITORY_NAME')) {
|
||||||
|
$obj['variables'].Remove('OCIR_REPOSITORY_NAME')
|
||||||
|
Write-Host " Chave OCIR_REPOSITORY_NAME removida do objeto" -ForegroundColor Green
|
||||||
|
} else {
|
||||||
|
Write-Host " OCIR_REPOSITORY_NAME nao encontrada" -ForegroundColor Yellow
|
||||||
|
}
|
||||||
|
|
||||||
|
# Adicionar projectReferences obrigatorio
|
||||||
|
$projRef = New-Object System.Collections.Generic.Dictionary'[string,object]'
|
||||||
|
$projRef['name'] = 'oci-terraform'
|
||||||
|
$innerProj = New-Object System.Collections.Generic.Dictionary'[string,object]'
|
||||||
|
$innerProj['id'] = $projectId
|
||||||
|
$innerProj['name'] = 'Invista FIDC - Nexus'
|
||||||
|
$projRef['projectReference'] = $innerProj
|
||||||
|
$obj['projectReferences'] = @($projRef)
|
||||||
|
|
||||||
|
$updatedJson = $serializer.Serialize($obj)
|
||||||
|
|
||||||
|
Write-Host "=== 1. PUT oci-terraform sem OCIR_REPOSITORY_NAME ===" -ForegroundColor Cyan
|
||||||
|
try {
|
||||||
|
$result = Invoke-RestMethod -Uri "$base/distributedtask/variablegroups/$vgId`?api-version=7.0" -Method PUT -Headers $h -Body $updatedJson -ErrorAction Stop
|
||||||
|
$vars = $result.variables.PSObject.Properties.Name
|
||||||
|
if ('OCIR_REPOSITORY_NAME' -in $vars) {
|
||||||
|
Write-Host " AVISO: variavel ainda presente" -ForegroundColor Yellow
|
||||||
|
} else {
|
||||||
|
Write-Host " OK - removida. Variaveis: $($vars -join ', ')" -ForegroundColor Green
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
$errRaw = $_.ErrorDetails.Message
|
||||||
|
try { $errMsg = ($errRaw | ConvertFrom-Json).message } catch { $errMsg = $errRaw }
|
||||||
|
Write-Host " ERRO: $errMsg" -ForegroundColor Red
|
||||||
|
# Debug: mostrar os primeiros 300 chars do body
|
||||||
|
Write-Host " Body (300 chars): $($updatedJson.Substring(0, [Math]::Min(300, $updatedJson.Length)))"
|
||||||
|
}
|
||||||
|
|
||||||
|
# =====================================================================
|
||||||
|
# 2. Criar VG ms-parameters-dev
|
||||||
|
# =====================================================================
|
||||||
|
Write-Host "`n=== 2. Criando VG ms-parameters-dev ===" -ForegroundColor Cyan
|
||||||
|
|
||||||
|
$vgs = Invoke-RestMethod -Uri "$base/distributedtask/variablegroups?api-version=7.0" -Headers $h
|
||||||
|
$existing = $vgs.value | Where-Object { $_.name -eq 'ms-parameters-dev' }
|
||||||
|
if ($existing) {
|
||||||
|
Write-Host " Ja existe (ID: $($existing.id))" -ForegroundColor Yellow
|
||||||
|
} else {
|
||||||
|
$newProjRef = @(
|
||||||
|
@{
|
||||||
|
name = 'ms-parameters-dev'
|
||||||
|
projectReference = @{ id = $projectId; name = 'Invista FIDC - Nexus' }
|
||||||
|
}
|
||||||
|
)
|
||||||
|
$newVg = @{
|
||||||
|
name = 'ms-parameters-dev'
|
||||||
|
type = 'Vsts'
|
||||||
|
variables = @{
|
||||||
|
CLUSTER_NAME = @{ value = 'NexusCluster'; isSecret = $false }
|
||||||
|
LOG_GROUP_NAME = @{ value = '/ecs/logs'; isSecret = $false }
|
||||||
|
TASK_CONTAINER_NAME = @{ value = 'ms-parameters'; isSecret = $false }
|
||||||
|
TASK_FAMILY = @{ value = 'ms-parameters'; isSecret = $false }
|
||||||
|
TASK_EXECUTION_ROLE_ARN = @{ value = ''; isSecret = $true }
|
||||||
|
TASK_ROLE_ARN = @{ value = ''; isSecret = $true }
|
||||||
|
LAST_SWAGGER_HASH = @{ value = ''; isSecret = $false }
|
||||||
|
}
|
||||||
|
projectReferences = $newProjRef
|
||||||
|
} | ConvertTo-Json -Depth 6
|
||||||
|
|
||||||
|
try {
|
||||||
|
$created = Invoke-RestMethod -Uri "$base/distributedtask/variablegroups?api-version=7.0" -Method POST -Headers $h -Body $newVg -ErrorAction Stop
|
||||||
|
Write-Host " OK - criado: $($created.name) (ID: $($created.id))" -ForegroundColor Green
|
||||||
|
} catch {
|
||||||
|
$errRaw = $_.ErrorDetails.Message
|
||||||
|
try { $errMsg = ($errRaw | ConvertFrom-Json).message } catch { $errMsg = $errRaw }
|
||||||
|
Write-Host " ERRO: $errMsg" -ForegroundColor Red
|
||||||
|
}
|
||||||
|
}
|
||||||
98
scripts/auto-organized/fix_vg6.ps1
Normal file
98
scripts/auto-organized/fix_vg6.ps1
Normal file
|
|
@ -0,0 +1,98 @@
|
||||||
|
$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp'
|
||||||
|
$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p))
|
||||||
|
$h = @{ Authorization = 'Basic ' + $t; 'Content-Type' = 'application/json' }
|
||||||
|
$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis'
|
||||||
|
$projectId = '28c26924-b0a7-485d-b8c2-c86e48377e85'
|
||||||
|
$vgId = 34
|
||||||
|
|
||||||
|
# GET VG por ID (nao pela lista)
|
||||||
|
$vg = Invoke-RestMethod -Uri "$base/distributedtask/variablegroups/$vgId`?api-version=7.0" -Headers $h
|
||||||
|
|
||||||
|
# =====================================================================
|
||||||
|
# 1. Remover OCIR_REPOSITORY_NAME
|
||||||
|
# =====================================================================
|
||||||
|
Write-Host "=== 1. Removendo OCIR_REPOSITORY_NAME do oci-terraform ===" -ForegroundColor Cyan
|
||||||
|
Write-Host " Variaveis atuais: $($vg.variables.PSObject.Properties.Name -join ', ')"
|
||||||
|
|
||||||
|
# Construir novo objeto de variaveis
|
||||||
|
$newVars = [ordered]@{}
|
||||||
|
foreach ($prop in $vg.variables.PSObject.Properties) {
|
||||||
|
if ($prop.Name -ne 'OCIR_REPOSITORY_NAME') {
|
||||||
|
# Preservar isSecret e value
|
||||||
|
$entry = @{}
|
||||||
|
if ($null -ne $prop.Value.isSecret -and $prop.Value.isSecret -eq $true) {
|
||||||
|
$entry['isSecret'] = $true
|
||||||
|
# Nao incluir value para secrets (o servidor mantem o valor)
|
||||||
|
} else {
|
||||||
|
$entry['isSecret'] = $false
|
||||||
|
$entry['value'] = if ($null -ne $prop.Value.value) { $prop.Value.value } else { '' }
|
||||||
|
}
|
||||||
|
$newVars[$prop.Name] = $entry
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Write-Host " Variaveis novas ($($newVars.Count)): $($newVars.Keys -join ', ')"
|
||||||
|
|
||||||
|
$updateBody = [ordered]@{
|
||||||
|
id = $vg.id
|
||||||
|
name = $vg.name
|
||||||
|
type = $vg.type
|
||||||
|
description = $vg.description
|
||||||
|
variables = $newVars
|
||||||
|
} | ConvertTo-Json -Depth 8
|
||||||
|
|
||||||
|
try {
|
||||||
|
$result = Invoke-RestMethod -Uri "$base/distributedtask/variablegroups/$vgId`?api-version=7.0" -Method PUT -Headers $h -Body $updateBody -ErrorAction Stop
|
||||||
|
$vars = $result.variables.PSObject.Properties.Name
|
||||||
|
if ('OCIR_REPOSITORY_NAME' -in $vars) {
|
||||||
|
Write-Host " AVISO: variavel ainda presente" -ForegroundColor Yellow
|
||||||
|
} else {
|
||||||
|
Write-Host " OK - removida. Total: $($vars.Count) variaveis" -ForegroundColor Green
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
$errRaw = $_.ErrorDetails.Message
|
||||||
|
try { $errMsg = ($errRaw | ConvertFrom-Json).message } catch { $errMsg = $errRaw }
|
||||||
|
Write-Host " ERRO: $errMsg" -ForegroundColor Red
|
||||||
|
}
|
||||||
|
|
||||||
|
# =====================================================================
|
||||||
|
# 2. Criar VG ms-parameters-dev
|
||||||
|
# =====================================================================
|
||||||
|
Write-Host "`n=== 2. Criando VG ms-parameters-dev ===" -ForegroundColor Cyan
|
||||||
|
|
||||||
|
$vgsCheck = Invoke-RestMethod -Uri "$base/distributedtask/variablegroups?api-version=7.0" -Headers $h
|
||||||
|
$existing = $vgsCheck.value | Where-Object { $_.name -eq 'ms-parameters-dev' }
|
||||||
|
if ($existing) {
|
||||||
|
Write-Host " Ja existe (ID: $($existing.id))" -ForegroundColor Yellow
|
||||||
|
} else {
|
||||||
|
# Tentar criar sem projectReferences (endpoint de projeto ja tem contexto)
|
||||||
|
$newVgBody = [ordered]@{
|
||||||
|
name = 'ms-parameters-dev'
|
||||||
|
type = 'Vsts'
|
||||||
|
variables = [ordered]@{
|
||||||
|
CLUSTER_NAME = @{ value = 'NexusCluster'; isSecret = $false }
|
||||||
|
LOG_GROUP_NAME = @{ value = '/ecs/logs'; isSecret = $false }
|
||||||
|
TASK_CONTAINER_NAME = @{ value = 'ms-parameters'; isSecret = $false }
|
||||||
|
TASK_FAMILY = @{ value = 'ms-parameters'; isSecret = $false }
|
||||||
|
TASK_EXECUTION_ROLE_ARN = @{ value = ''; isSecret = $true }
|
||||||
|
TASK_ROLE_ARN = @{ value = ''; isSecret = $true }
|
||||||
|
LAST_SWAGGER_HASH = @{ value = ''; isSecret = $false }
|
||||||
|
}
|
||||||
|
projectReferences = @(
|
||||||
|
[ordered]@{
|
||||||
|
name = 'ms-parameters-dev'
|
||||||
|
projectReference = [ordered]@{ id = $projectId }
|
||||||
|
}
|
||||||
|
)
|
||||||
|
} | ConvertTo-Json -Depth 6
|
||||||
|
|
||||||
|
try {
|
||||||
|
$created = Invoke-RestMethod -Uri "$base/distributedtask/variablegroups?api-version=7.0" -Method POST -Headers $h -Body $newVgBody -ErrorAction Stop
|
||||||
|
Write-Host " OK - criado: $($created.name) (ID: $($created.id))" -ForegroundColor Green
|
||||||
|
} catch {
|
||||||
|
$errRaw = $_.ErrorDetails.Message
|
||||||
|
try { $errMsg = ($errRaw | ConvertFrom-Json).message } catch { $errMsg = $errRaw }
|
||||||
|
Write-Host " ERRO: $errMsg" -ForegroundColor Red
|
||||||
|
Write-Host " Body enviado:" -ForegroundColor Gray
|
||||||
|
Write-Host $newVgBody
|
||||||
|
}
|
||||||
|
}
|
||||||
93
scripts/auto-organized/fix_vg7.ps1
Normal file
93
scripts/auto-organized/fix_vg7.ps1
Normal file
|
|
@ -0,0 +1,93 @@
|
||||||
|
$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp'
|
||||||
|
$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p))
|
||||||
|
$h = @{ Authorization = 'Basic ' + $t; 'Content-Type' = 'application/json' }
|
||||||
|
$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis'
|
||||||
|
$projectId = '28c26924-b0a7-485d-b8c2-c86e48377e85'
|
||||||
|
$vgId = 34
|
||||||
|
|
||||||
|
$vg = Invoke-RestMethod -Uri "$base/distributedtask/variablegroups/$vgId`?api-version=7.0" -Headers $h
|
||||||
|
|
||||||
|
# =====================================================================
|
||||||
|
# 1. Remover OCIR_REPOSITORY_NAME
|
||||||
|
# =====================================================================
|
||||||
|
Write-Host "=== 1. Removendo OCIR_REPOSITORY_NAME do oci-terraform ===" -ForegroundColor Cyan
|
||||||
|
|
||||||
|
$newVars = [ordered]@{}
|
||||||
|
foreach ($prop in $vg.variables.PSObject.Properties) {
|
||||||
|
if ($prop.Name -ne 'OCIR_REPOSITORY_NAME') {
|
||||||
|
$entry = @{}
|
||||||
|
if ($prop.Value.isSecret -eq $true) {
|
||||||
|
$entry['isSecret'] = $true
|
||||||
|
} else {
|
||||||
|
$entry['isSecret'] = $false
|
||||||
|
$entry['value'] = if ($null -ne $prop.Value.value) { [string]$prop.Value.value } else { '' }
|
||||||
|
}
|
||||||
|
$newVars[$prop.Name] = $entry
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Tentar diferentes versoes da API
|
||||||
|
foreach ($apiVer in @('7.1-preview.2', '7.0', '6.0', '5.1-preview.1')) {
|
||||||
|
$updateBody = [ordered]@{
|
||||||
|
id = [int]$vg.id
|
||||||
|
name = [string]$vg.name
|
||||||
|
type = [string]$vg.type
|
||||||
|
variables = $newVars
|
||||||
|
} | ConvertTo-Json -Depth 8
|
||||||
|
|
||||||
|
$url = "$base/distributedtask/variablegroups/$vgId`?api-version=$apiVer"
|
||||||
|
Write-Host " Tentando api-version=$apiVer ..."
|
||||||
|
try {
|
||||||
|
$result = Invoke-RestMethod -Uri $url -Method PUT -Headers $h -Body $updateBody -ErrorAction Stop
|
||||||
|
$vars = $result.variables.PSObject.Properties.Name
|
||||||
|
if ('OCIR_REPOSITORY_NAME' -in $vars) {
|
||||||
|
Write-Host " AVISO: ainda presente" -ForegroundColor Yellow
|
||||||
|
} else {
|
||||||
|
Write-Host " OK com api-version=$apiVer" -ForegroundColor Green
|
||||||
|
}
|
||||||
|
break
|
||||||
|
} catch {
|
||||||
|
$errRaw = $_.ErrorDetails.Message
|
||||||
|
try { $errMsg = ($errRaw | ConvertFrom-Json).message } catch { $errMsg = $errRaw }
|
||||||
|
Write-Host " ERRO ($apiVer): $errMsg" -ForegroundColor Red
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# =====================================================================
|
||||||
|
# 2. Criar VG ms-parameters-dev
|
||||||
|
# =====================================================================
|
||||||
|
Write-Host "`n=== 2. Criando VG ms-parameters-dev ===" -ForegroundColor Cyan
|
||||||
|
|
||||||
|
$vgsCheck = Invoke-RestMethod -Uri "$base/distributedtask/variablegroups?api-version=7.0" -Headers $h
|
||||||
|
$existing = $vgsCheck.value | Where-Object { $_.name -eq 'ms-parameters-dev' }
|
||||||
|
if ($existing) {
|
||||||
|
Write-Host " Ja existe (ID: $($existing.id))" -ForegroundColor Yellow
|
||||||
|
} else {
|
||||||
|
foreach ($apiVer in @('7.1-preview.2', '7.0', '6.0', '5.1-preview.1')) {
|
||||||
|
$newVgBody = [ordered]@{
|
||||||
|
name = 'ms-parameters-dev'
|
||||||
|
type = 'Vsts'
|
||||||
|
variables = [ordered]@{
|
||||||
|
CLUSTER_NAME = @{ value = 'NexusCluster'; isSecret = $false }
|
||||||
|
LOG_GROUP_NAME = @{ value = '/ecs/logs'; isSecret = $false }
|
||||||
|
TASK_CONTAINER_NAME = @{ value = 'ms-parameters'; isSecret = $false }
|
||||||
|
TASK_FAMILY = @{ value = 'ms-parameters'; isSecret = $false }
|
||||||
|
TASK_EXECUTION_ROLE_ARN = @{ value = ''; isSecret = $true }
|
||||||
|
TASK_ROLE_ARN = @{ value = ''; isSecret = $true }
|
||||||
|
LAST_SWAGGER_HASH = @{ value = ''; isSecret = $false }
|
||||||
|
}
|
||||||
|
} | ConvertTo-Json -Depth 6
|
||||||
|
|
||||||
|
$url = "$base/distributedtask/variablegroups?api-version=$apiVer"
|
||||||
|
Write-Host " Tentando api-version=$apiVer ..."
|
||||||
|
try {
|
||||||
|
$created = Invoke-RestMethod -Uri $url -Method POST -Headers $h -Body $newVgBody -ErrorAction Stop
|
||||||
|
Write-Host " OK - criado: $($created.name) (ID: $($created.id)) com api-version=$apiVer" -ForegroundColor Green
|
||||||
|
break
|
||||||
|
} catch {
|
||||||
|
$errRaw = $_.ErrorDetails.Message
|
||||||
|
try { $errMsg = ($errRaw | ConvertFrom-Json).message } catch { $errMsg = $errRaw }
|
||||||
|
Write-Host " ERRO ($apiVer): $errMsg" -ForegroundColor Red
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
1
scripts/auto-organized/forgejo_create_icatu.json
Normal file
1
scripts/auto-organized/forgejo_create_icatu.json
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{"name":"icatu","private":true,"description":"Monorepo icatu"}
|
||||||
38
scripts/auto-organized/get_build_log.ps1
Normal file
38
scripts/auto-organized/get_build_log.ps1
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp'
|
||||||
|
$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p))
|
||||||
|
$h = @{ Authorization = 'Basic ' + $t }
|
||||||
|
$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis'
|
||||||
|
|
||||||
|
# Buscar os 10 builds mais recentes do projeto (qualquer pipeline, branch devops)
|
||||||
|
$builds = Invoke-RestMethod -Uri "$base/build/builds?branchName=refs/heads/devops&`$top=10&api-version=7.0" -Headers $h
|
||||||
|
Write-Host "Builds recentes na branch devops:"
|
||||||
|
$builds.value | Select-Object id,
|
||||||
|
@{n='pipeline';e={$_.definition.name}},
|
||||||
|
@{n='status';e={$_.status}},
|
||||||
|
@{n='result';e={if($_.result){$_.result}else{'(running)'}}},
|
||||||
|
@{n='queued';e={$_.queueTime}} |
|
||||||
|
Format-Table
|
||||||
|
|
||||||
|
# Pegar o mais recente do mfe-shell
|
||||||
|
$shell = $builds.value | Where-Object { $_.definition.name -eq 'mfe-shell' } | Select-Object -First 1
|
||||||
|
if ($shell) {
|
||||||
|
$buildId = $shell.id
|
||||||
|
Write-Host "=== mfe-shell build mais recente: $buildId ==="
|
||||||
|
if ($shell.validationResults) {
|
||||||
|
Write-Host "VALIDATION ERRORS:"
|
||||||
|
$shell.validationResults | ForEach-Object { Write-Host " [$($_.result)] $($_.message)" }
|
||||||
|
}
|
||||||
|
$tl = Invoke-RestMethod -Uri "$base/build/builds/$buildId/timeline?api-version=7.0" -Headers $h
|
||||||
|
if ($tl.records.Count -gt 0) {
|
||||||
|
$tl.records | Where-Object { $_.result -eq 'failed' } |
|
||||||
|
Select-Object type, name, result, errorCount | Format-Table
|
||||||
|
$failedStep = $tl.records | Where-Object { $_.result -eq 'failed' -and $_.type -eq 'Task' } | Select-Object -First 1
|
||||||
|
if ($failedStep -and $failedStep.log) {
|
||||||
|
Write-Host "LOG: $($failedStep.name)"
|
||||||
|
$logContent = Invoke-RestMethod -Uri "$($failedStep.log.url)?api-version=7.0" -Headers $h
|
||||||
|
$logContent -split "`n" | Select-Object -Last 40 | ForEach-Object { Write-Host $_ }
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Write-Host "Timeline vazia."
|
||||||
|
}
|
||||||
|
}
|
||||||
38
scripts/auto-organized/get_build_log2.ps1
Normal file
38
scripts/auto-organized/get_build_log2.ps1
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp'
|
||||||
|
$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p))
|
||||||
|
$h = @{ Authorization = 'Basic ' + $t }
|
||||||
|
$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis'
|
||||||
|
|
||||||
|
# Buscar os 10 builds mais recentes do projeto (qualquer pipeline, branch devops)
|
||||||
|
$builds = Invoke-RestMethod -Uri "$base/build/builds?branchName=refs/heads/devops&`$top=10&api-version=7.0" -Headers $h
|
||||||
|
Write-Host "Builds recentes na branch devops:"
|
||||||
|
$builds.value | Select-Object id,
|
||||||
|
@{n='pipeline';e={$_.definition.name}},
|
||||||
|
@{n='status';e={$_.status}},
|
||||||
|
@{n='result';e={if($_.result){$_.result}else{'(running)'}}},
|
||||||
|
@{n='queued';e={$_.queueTime}} |
|
||||||
|
Format-Table
|
||||||
|
|
||||||
|
# Pegar o mais recente do mfe-shell
|
||||||
|
$shell = $builds.value | Where-Object { $_.definition.name -eq 'mfe-shell' } | Select-Object -First 1
|
||||||
|
if ($shell) {
|
||||||
|
$buildId = $shell.id
|
||||||
|
Write-Host "=== mfe-shell build mais recente: $buildId ==="
|
||||||
|
if ($shell.validationResults) {
|
||||||
|
Write-Host "VALIDATION ERRORS:"
|
||||||
|
$shell.validationResults | ForEach-Object { Write-Host " [$($_.result)] $($_.message)" }
|
||||||
|
}
|
||||||
|
$tl = Invoke-RestMethod -Uri "$base/build/builds/$buildId/timeline?api-version=7.0" -Headers $h
|
||||||
|
if ($tl.records.Count -gt 0) {
|
||||||
|
$tl.records | Where-Object { $_.result -eq 'failed' } |
|
||||||
|
Select-Object type, name, result, errorCount | Format-Table
|
||||||
|
$failedStep = $tl.records | Where-Object { $_.result -eq 'failed' -and $_.type -eq 'Task' } | Select-Object -First 1
|
||||||
|
if ($failedStep -and $failedStep.log) {
|
||||||
|
Write-Host "LOG: $($failedStep.name)"
|
||||||
|
$logContent = Invoke-RestMethod -Uri "$($failedStep.log.url)?api-version=7.0" -Headers $h
|
||||||
|
$logContent -split "`n" | Select-Object -Last 40 | ForEach-Object { Write-Host $_ }
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Write-Host "Timeline vazia."
|
||||||
|
}
|
||||||
|
}
|
||||||
13
scripts/auto-organized/get_cf_records.ps1
Normal file
13
scripts/auto-organized/get_cf_records.ps1
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
$email = 'tiago.ribeiro@inventcloud.com.br'
|
||||||
|
$key = '7ae5565ab2dcdfdfdd66efb1105e27d18d186'
|
||||||
|
$h = @{ 'X-Auth-Email' = $email; 'X-Auth-Key' = $key; 'Content-Type' = 'application/json' }
|
||||||
|
|
||||||
|
$zones = Invoke-RestMethod 'https://api.cloudflare.com/client/v4/zones?name=invista.com.br' -Headers $h
|
||||||
|
$zoneId = $zones.result[0].id
|
||||||
|
Write-Host "Zone ID: $zoneId"
|
||||||
|
|
||||||
|
$records = Invoke-RestMethod "https://api.cloudflare.com/client/v4/zones/$zoneId/dns_records?per_page=100" -Headers $h
|
||||||
|
$records.result | Where-Object { $_.name -match 'crivo|mfe|shell|user' } | ForEach-Object {
|
||||||
|
$proxied = if ($_.proxied) { "PROX" } else { "NOPROX" }
|
||||||
|
Write-Host "$($_.type) $proxied $($_.name) -> $($_.content)"
|
||||||
|
}
|
||||||
23
scripts/auto-organized/inspect_vg.ps1
Normal file
23
scripts/auto-organized/inspect_vg.ps1
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp'
|
||||||
|
$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p))
|
||||||
|
$h = @{ Authorization = 'Basic ' + $t }
|
||||||
|
$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis'
|
||||||
|
|
||||||
|
# GET raw JSON do VG 34 (oci-terraform) via WebClient para ver estrutura completa
|
||||||
|
$wc = New-Object System.Net.WebClient
|
||||||
|
$wc.Headers['Authorization'] = 'Basic ' + $t
|
||||||
|
$raw = $wc.DownloadString("$base/distributedtask/variablegroups/34?api-version=7.0")
|
||||||
|
$json = $raw | ConvertFrom-Json
|
||||||
|
|
||||||
|
# Mostrar apenas a estrutura (sem os valores das variaveis)
|
||||||
|
Write-Host "=== Estrutura do VG ===" -ForegroundColor Cyan
|
||||||
|
Write-Host "id: $($json.id)"
|
||||||
|
Write-Host "name: $($json.name)"
|
||||||
|
Write-Host "type: $($json.type)"
|
||||||
|
Write-Host "projectReferences: $($json.projectReferences | ConvertTo-Json -Depth 5)"
|
||||||
|
Write-Host "variables (keys): $($json.variables.PSObject.Properties.Name -join ', ')"
|
||||||
|
|
||||||
|
# Mostrar o JSON completo (sem valores secretos)
|
||||||
|
Write-Host "`n=== JSON completo (sem variaveis) ===" -ForegroundColor Cyan
|
||||||
|
$jsonClean = $json | Select-Object id, name, type, projectReferences, description
|
||||||
|
$jsonClean | ConvertTo-Json -Depth 5
|
||||||
27
scripts/auto-organized/lb_rules.json
Normal file
27
scripts/auto-organized/lb_rules.json
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "crivo_dev_adm",
|
||||||
|
"condition": "all(http.request.headers[(i 'host')] eq (i 'crivo-dev-adm.invista.com.br'))",
|
||||||
|
"actions": [{"name": "FORWARD_TO_BACKENDSET", "backendSetName": "Dev_Crivo_BS_84"}]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "crivo_dev",
|
||||||
|
"condition": "all(http.request.headers[(i 'host')] eq (i 'crivo-dev.invista.com.br'))",
|
||||||
|
"actions": [{"name": "FORWARD_TO_BACKENDSET", "backendSetName": "Dev_Crivo_BS_80"}]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "mfe_user_dev",
|
||||||
|
"condition": "all(http.request.headers[(i 'host')] eq (i 'mfe-user-dev.invista.com.br'))",
|
||||||
|
"actions": [{"name": "FORWARD_TO_BACKENDSET", "backendSetName": "bs-mfe-user-dev"}]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "mfe_shell_dev",
|
||||||
|
"condition": "all(http.request.headers[(i 'host')] eq (i 'mfe-shell-dev.invista.com.br'))",
|
||||||
|
"actions": [{"name": "FORWARD_TO_BACKENDSET", "backendSetName": "bs-mfe-shell-dev"}]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "mfe_shell_dev_oci",
|
||||||
|
"condition": "all(http.request.headers[(i 'host')] eq (i 'mfe-shell-dev-oci.invista.com.br'))",
|
||||||
|
"actions": [{"name": "FORWARD_TO_BACKENDSET", "backendSetName": "bs-mfe-shell-dev-oci"}]
|
||||||
|
}
|
||||||
|
]
|
||||||
66
scripts/auto-organized/merge_templates.ps1
Normal file
66
scripts/auto-organized/merge_templates.ps1
Normal file
|
|
@ -0,0 +1,66 @@
|
||||||
|
$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp'
|
||||||
|
$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p))
|
||||||
|
$h = @{ Authorization = 'Basic ' + $t; 'Content-Type' = 'application/json' }
|
||||||
|
$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis'
|
||||||
|
|
||||||
|
# 1. Achar o repo azure-pipelines-templates
|
||||||
|
$repos = Invoke-RestMethod -Uri "$base/git/repositories?api-version=7.0" -Headers $h
|
||||||
|
$repo = $repos.value | Where-Object { $_.name -eq 'azure-pipelines-templates' }
|
||||||
|
|
||||||
|
if (-not $repo) {
|
||||||
|
Write-Host "ERRO: repo azure-pipelines-templates nao encontrado" -ForegroundColor Red
|
||||||
|
$repos.value | Select-Object name, id | Format-Table
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "Repo: $($repo.name) - ID: $($repo.id)" -ForegroundColor Cyan
|
||||||
|
$repoId = $repo.id
|
||||||
|
|
||||||
|
# 2. Pegar SHA da feature branch
|
||||||
|
$featureRef = Invoke-RestMethod -Uri "$base/git/repositories/$repoId/refs?filter=heads/feature/cd-deploy-oci-oke`&api-version=7.0" -Headers $h
|
||||||
|
if ($featureRef.count -eq 0) {
|
||||||
|
Write-Host "ERRO: branch feature/cd-deploy-oci-oke nao encontrada" -ForegroundColor Red
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
$featureSha = $featureRef.value[0].objectId
|
||||||
|
Write-Host " SHA feature: $featureSha"
|
||||||
|
|
||||||
|
# 3. Pegar SHA do main
|
||||||
|
$mainRef = Invoke-RestMethod -Uri "$base/git/repositories/$repoId/refs?filter=heads/main`&api-version=7.0" -Headers $h
|
||||||
|
if ($mainRef.count -eq 0) {
|
||||||
|
Write-Host "ERRO: branch main nao encontrada" -ForegroundColor Red
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
$mainSha = $mainRef.value[0].objectId
|
||||||
|
Write-Host " SHA main: $mainSha"
|
||||||
|
|
||||||
|
# 4. Criar PR de feature/cd-deploy-oci-oke -> main
|
||||||
|
$prBody = @{
|
||||||
|
title = 'chore: merge feature/cd-deploy-oci-oke into main'
|
||||||
|
description = 'Merge dos templates OCI/OKE para main'
|
||||||
|
sourceRefName = 'refs/heads/feature/cd-deploy-oci-oke'
|
||||||
|
targetRefName = 'refs/heads/main'
|
||||||
|
completionOptions = @{
|
||||||
|
mergeStrategy = 'squash'
|
||||||
|
deleteSourceBranch = $false
|
||||||
|
}
|
||||||
|
} | ConvertTo-Json -Depth 5
|
||||||
|
|
||||||
|
Write-Host "Criando PR..." -ForegroundColor Cyan
|
||||||
|
$pr = Invoke-RestMethod -Uri "$base/git/repositories/$repoId/pullrequests?api-version=7.0" -Method POST -Headers $h -Body $prBody -ErrorAction Stop
|
||||||
|
$prId = $pr.pullRequestId
|
||||||
|
Write-Host " PR criado: #$prId" -ForegroundColor Green
|
||||||
|
|
||||||
|
# 5. Completar o PR (merge)
|
||||||
|
$completeBody = @{
|
||||||
|
status = 'completed'
|
||||||
|
lastMergeSourceCommit = @{ commitId = $featureSha }
|
||||||
|
completionOptions = @{
|
||||||
|
mergeStrategy = 'squash'
|
||||||
|
deleteSourceBranch = $false
|
||||||
|
}
|
||||||
|
} | ConvertTo-Json -Depth 5
|
||||||
|
|
||||||
|
Write-Host " Completando PR #$prId..." -ForegroundColor Cyan
|
||||||
|
$result = Invoke-RestMethod -Uri "$base/git/repositories/$repoId/pullrequests/$prId`?api-version=7.0" -Method PATCH -Headers $h -Body $completeBody -ErrorAction Stop
|
||||||
|
Write-Host " Status: $($result.status)" -ForegroundColor Green
|
||||||
40
scripts/auto-organized/mfe_shell_spa_spec.json
Normal file
40
scripts/auto-organized/mfe_shell_spa_spec.json
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
{
|
||||||
|
"routes": [
|
||||||
|
{
|
||||||
|
"path": "/",
|
||||||
|
"methods": ["GET"],
|
||||||
|
"backend": {
|
||||||
|
"type": "HTTP_BACKEND",
|
||||||
|
"url": "https://objectstorage.sa-saopaulo-1.oraclecloud.com/n/grbb7qzeuoag/b/mfe-shell-dev/o/index.html",
|
||||||
|
"connectTimeoutInSeconds": 10,
|
||||||
|
"readTimeoutInSeconds": 30,
|
||||||
|
"sendTimeoutInSeconds": 10,
|
||||||
|
"isSslVerifyDisabled": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "/{file}",
|
||||||
|
"methods": ["GET"],
|
||||||
|
"backend": {
|
||||||
|
"type": "HTTP_BACKEND",
|
||||||
|
"url": "https://objectstorage.sa-saopaulo-1.oraclecloud.com/n/grbb7qzeuoag/b/mfe-shell-dev/o/${request.path[file]}",
|
||||||
|
"connectTimeoutInSeconds": 10,
|
||||||
|
"readTimeoutInSeconds": 30,
|
||||||
|
"sendTimeoutInSeconds": 10,
|
||||||
|
"isSslVerifyDisabled": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "/{path*}",
|
||||||
|
"methods": ["GET"],
|
||||||
|
"backend": {
|
||||||
|
"type": "HTTP_BACKEND",
|
||||||
|
"url": "https://objectstorage.sa-saopaulo-1.oraclecloud.com/n/grbb7qzeuoag/b/mfe-shell-dev/o/index.html",
|
||||||
|
"connectTimeoutInSeconds": 10,
|
||||||
|
"readTimeoutInSeconds": 30,
|
||||||
|
"sendTimeoutInSeconds": 10,
|
||||||
|
"isSslVerifyDisabled": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
40
scripts/auto-organized/mfe_shell_spec.json
Normal file
40
scripts/auto-organized/mfe_shell_spec.json
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
{
|
||||||
|
"routes": [
|
||||||
|
{
|
||||||
|
"path": "/",
|
||||||
|
"methods": ["GET"],
|
||||||
|
"backend": {
|
||||||
|
"type": "HTTP_BACKEND",
|
||||||
|
"url": "https://objectstorage.sa-saopaulo-1.oraclecloud.com/n/grbb7qzeuoag/b/mfe-shell-dev/o/index.html",
|
||||||
|
"connectTimeoutInSeconds": 10,
|
||||||
|
"readTimeoutInSeconds": 30,
|
||||||
|
"sendTimeoutInSeconds": 10,
|
||||||
|
"isSslVerifyDisabled": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "/{file}",
|
||||||
|
"methods": ["GET"],
|
||||||
|
"backend": {
|
||||||
|
"type": "HTTP_BACKEND",
|
||||||
|
"url": "https://objectstorage.sa-saopaulo-1.oraclecloud.com/n/grbb7qzeuoag/b/mfe-shell-dev/o/${request.path[file]}",
|
||||||
|
"connectTimeoutInSeconds": 10,
|
||||||
|
"readTimeoutInSeconds": 30,
|
||||||
|
"sendTimeoutInSeconds": 10,
|
||||||
|
"isSslVerifyDisabled": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "/{path*}",
|
||||||
|
"methods": ["GET"],
|
||||||
|
"backend": {
|
||||||
|
"type": "HTTP_BACKEND",
|
||||||
|
"url": "https://objectstorage.sa-saopaulo-1.oraclecloud.com/n/grbb7qzeuoag/b/mfe-shell-dev/o/index.html",
|
||||||
|
"connectTimeoutInSeconds": 10,
|
||||||
|
"readTimeoutInSeconds": 30,
|
||||||
|
"sendTimeoutInSeconds": 10,
|
||||||
|
"isSslVerifyDisabled": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
28
scripts/auto-organized/private_key.pem
Normal file
28
scripts/auto-organized/private_key.pem
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
-----BEGIN PRIVATE KEY-----
|
||||||
|
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCc9suDobwJwCGJ
|
||||||
|
VFvga1BxKkmmGOxoF8zNibv6l33/SCFEBb5fFaenxvYotEGWUw0fed4zIcX3s6hA
|
||||||
|
q2yLr3nIygpLpcOfzpzPxas49P17NA3Chvo3k/0eGkBD6PHM1s62qPP+fKEZtwlS
|
||||||
|
q1WaFxfc949iqJAQvW6w/7WgMZDineq3IzhVVUAFdw3icZru97hCjPDU/v3eFTS7
|
||||||
|
kvGrDYGAHZXzylu3Er9ifKYHdKxOrWFmGaSsPsYMdKNxWFk+Z38NVUnwSH3TEiV/
|
||||||
|
S4e33tTkdMmNpY+6e9Cigb09RnOalj5lPjFGA9nTHMJxpsHvSKu8vMBr+OZ4CM3U
|
||||||
|
RH7MUX01AgMBAAECggEAMKxdFo/4MePY4m984B4W/0iYNv/iizLaKOBtoLsKcLeK
|
||||||
|
zT+ktXKPHzlUyvF+pyFQ3/JYA24VKAcXhRpDWhuLfcadI7Ee9PbKbKmEu3BJDEPr
|
||||||
|
gmd9vu9Ond+RDx30oUr5Je5FXySBhmpaYz7LGDHSDgzcc0EHD5HWed+JkEfegE7w
|
||||||
|
Mvt9KK41mGdaQwiPHS43uzZhQJEqybP3i/6SUnV2CntOhutxLlPk2rpHnns0p/St
|
||||||
|
Dvlcv61vduIaej4IFBrpSwTE45pvIfkvNZx0pJapM1jZhe8F/2T7GtXDkoFQveo1
|
||||||
|
3YB1aadpCx7u28IzQTwBZVwqhCpi2a5+qVYUT0AU3wKBgQDYYUxQUBiUn6bXoAsx
|
||||||
|
JTozoX0K50cX2d8LVY1OUuhpRXbztS2XXtyfeoAQtEWoT3UO7vjEedWswfo2j+N3
|
||||||
|
ZIXig7Vyj/LN5lZyCwWYn4S4inESjKlzi4Pv8D4F+Fkgg0WsVgzbTa4P7faHnDNn
|
||||||
|
eEHdyJ/ZQ8+XYxBpSAE8ecWQlwKBgQC5tGbfzh77REsv1h6b87vulrGHc+OBITTU
|
||||||
|
YFu1YfXpvbXx9geRfNLDtUhUis6vgfcQV6sxZVf78UdlqiTBebRLpcvoBlHV/MPZ
|
||||||
|
T3TsZH1vXwiitOsBIFzKkn8xdjuN6mN5lLjI6KkYeVoULYiUNbiZ+Wi7PXBPnc5I
|
||||||
|
jBO5EayOEwKBgQDU2pnso24avhatJKX92WYwphpQoISCBPPxvV38/3fbHtdOFBte
|
||||||
|
PZYAV8wlIoEnecpoP1J+TG+Su1r9U3xq1XsTAYd7w/kQ7RZ6pzcBFWLE+oMSwUZs
|
||||||
|
AIFwhb8ttklOv3PJfPi2vuqMhwUuD81NarI4jwQYASnz/SKGvqtgp1VezwKBgDoL
|
||||||
|
DOx+/GgE3ItDHaYY9HCKYUq5Ci7eNij7RS7YQ4ifZzMNdygeH7JUAxuJlzh8IsDU
|
||||||
|
5gk2Z92zeGFqYLqoU5YhaC5Ja2K68mwFzcHlVt9skMJqUdm0R8x5JZBMKCkfTaA+
|
||||||
|
v9LsBY5Ev8b2xG2urNhTgEyl02jPJh6+yZtazthJAoGAHRIX/W0IlyaLno7WzAwM
|
||||||
|
lSsNfJpTvZmkri0UOGXM2YaKuQZ652t6EBDtfM7O16eV3KNBblt1LjItz/S8kiFi
|
||||||
|
Q8tGluO27Hn5/auixJjlcZnzoUXrEjAra8lmgAo41Dm0icDpLUzhixZ0qS8d6Yfp
|
||||||
|
RIT1IoWSuu2fvOOvqezq6bg=
|
||||||
|
-----END PRIVATE KEY-----
|
||||||
12
scripts/auto-organized/remotes.txt
Normal file
12
scripts/auto-organized/remotes.txt
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
dokku dokku@localhost:gohorsejobs (fetch)
|
||||||
|
dokku dokku@localhost:gohorsejobs (push)
|
||||||
|
dokku-frontend dokku@localhost:gohorse-frontend (fetch)
|
||||||
|
dokku-frontend dokku@localhost:gohorse-frontend (push)
|
||||||
|
dokku-restore dokku@localhost:gohorse-frontend (fetch)
|
||||||
|
dokku-restore dokku@localhost:gohorse-frontend (push)
|
||||||
|
forgejo git@pipe.gohorsejobs.com:bohessefm/gohorsejobs.git (fetch)
|
||||||
|
forgejo git@pipe.gohorsejobs.com:bohessefm/gohorsejobs.git (push)
|
||||||
|
origin git@github.com:rede5/gohorsejobs.git (fetch)
|
||||||
|
origin git@github.com:rede5/gohorsejobs.git (push)
|
||||||
|
pipe https://pipe.gohorsejobs.com/bohessefm/gohorsejobs.git (fetch)
|
||||||
|
pipe https://pipe.gohorsejobs.com/bohessefm/gohorsejobs.git (push)
|
||||||
60
scripts/auto-organized/retrigger_mfe_pipelines.ps1
Normal file
60
scripts/auto-organized/retrigger_mfe_pipelines.ps1
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp'
|
||||||
|
$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p))
|
||||||
|
$h = @{ Authorization = 'Basic ' + $t; 'Content-Type' = 'application/json' }
|
||||||
|
$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis'
|
||||||
|
|
||||||
|
$mfe_repos = [ordered]@{
|
||||||
|
'mfe-shell' = '9f652079-76d7-4415-8c26-e40fdbcb6120'
|
||||||
|
'mfe-auth' = '23a19757-99e8-41c1-8b2c-a4921fe3795c'
|
||||||
|
'mfe-user' = '2eea9c4e-195e-4fb6-ae0b-2da1a560bcdc'
|
||||||
|
'mfe-person' = '8580c8ba-57ab-40bd-9bc0-e967b40a4f39'
|
||||||
|
'mfe-poc' = '2090316d-09cc-4379-b821-85c874006e0a'
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($name in $mfe_repos.Keys) {
|
||||||
|
$id = $mfe_repos[$name]
|
||||||
|
Write-Host "=== $name ===" -ForegroundColor Cyan
|
||||||
|
|
||||||
|
$ref = Invoke-RestMethod -Uri "$base/git/repositories/$id/refs?filter=heads/devops&api-version=7.0" -Headers $h
|
||||||
|
$oldSha = $ref.value[0].objectId
|
||||||
|
|
||||||
|
# Faz um commit no .trigger para re-disparar a pipeline
|
||||||
|
$body = @{
|
||||||
|
refUpdates = @(@{ name = 'refs/heads/devops'; oldObjectId = $oldSha })
|
||||||
|
commits = @(@{
|
||||||
|
comment = "ci: re-trigger pipeline apos correcao do template"
|
||||||
|
changes = @(@{
|
||||||
|
changeType = 'add'
|
||||||
|
item = @{ path = '/.trigger' }
|
||||||
|
newContent = @{ content = (Get-Date -Format 'yyyy-MM-dd HH:mm:ss'); contentType = 'rawtext' }
|
||||||
|
})
|
||||||
|
})
|
||||||
|
} | ConvertTo-Json -Depth 10
|
||||||
|
|
||||||
|
try {
|
||||||
|
$result = Invoke-RestMethod -Uri "$base/git/repositories/$id/pushes?api-version=7.0" -Method POST -Headers $h -Body $body -ErrorAction Stop
|
||||||
|
Write-Host " OK - commit: $($result.commits[0].commitId)" -ForegroundColor Green
|
||||||
|
} catch {
|
||||||
|
# Arquivo .trigger pode ja existir — tentar com edit
|
||||||
|
$body2 = @{
|
||||||
|
refUpdates = @(@{ name = 'refs/heads/devops'; oldObjectId = $oldSha })
|
||||||
|
commits = @(@{
|
||||||
|
comment = "ci: re-trigger pipeline apos correcao do template"
|
||||||
|
changes = @(@{
|
||||||
|
changeType = 'edit'
|
||||||
|
item = @{ path = '/.trigger' }
|
||||||
|
newContent = @{ content = (Get-Date -Format 'yyyy-MM-dd HH:mm:ss'); contentType = 'rawtext' }
|
||||||
|
})
|
||||||
|
})
|
||||||
|
} | ConvertTo-Json -Depth 10
|
||||||
|
try {
|
||||||
|
$result2 = Invoke-RestMethod -Uri "$base/git/repositories/$id/pushes?api-version=7.0" -Method POST -Headers $h -Body $body2 -ErrorAction Stop
|
||||||
|
Write-Host " OK (edit) - commit: $($result2.commits[0].commitId)" -ForegroundColor Green
|
||||||
|
} catch {
|
||||||
|
Write-Host " ERRO: $_" -ForegroundColor Red
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "Pipelines re-disparadas. Monitorando aprovacoes por 3 min..." -ForegroundColor Cyan
|
||||||
60
scripts/auto-organized/retrigger_mfe_pipelines2.ps1
Normal file
60
scripts/auto-organized/retrigger_mfe_pipelines2.ps1
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp'
|
||||||
|
$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p))
|
||||||
|
$h = @{ Authorization = 'Basic ' + $t; 'Content-Type' = 'application/json' }
|
||||||
|
$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis'
|
||||||
|
|
||||||
|
$mfe_repos = [ordered]@{
|
||||||
|
'mfe-shell' = '9f652079-76d7-4415-8c26-e40fdbcb6120'
|
||||||
|
'mfe-auth' = '23a19757-99e8-41c1-8b2c-a4921fe3795c'
|
||||||
|
'mfe-user' = '2eea9c4e-195e-4fb6-ae0b-2da1a560bcdc'
|
||||||
|
'mfe-person' = '8580c8ba-57ab-40bd-9bc0-e967b40a4f39'
|
||||||
|
'mfe-poc' = '2090316d-09cc-4379-b821-85c874006e0a'
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($name in $mfe_repos.Keys) {
|
||||||
|
$id = $mfe_repos[$name]
|
||||||
|
Write-Host "=== $name ===" -ForegroundColor Cyan
|
||||||
|
|
||||||
|
$ref = Invoke-RestMethod -Uri "$base/git/repositories/$id/refs?filter=heads/devops&api-version=7.0" -Headers $h
|
||||||
|
$oldSha = $ref.value[0].objectId
|
||||||
|
|
||||||
|
# Faz um commit no .trigger para re-disparar a pipeline
|
||||||
|
$body = @{
|
||||||
|
refUpdates = @(@{ name = 'refs/heads/devops'; oldObjectId = $oldSha })
|
||||||
|
commits = @(@{
|
||||||
|
comment = "ci: re-trigger pipeline apos correcao do template"
|
||||||
|
changes = @(@{
|
||||||
|
changeType = 'add'
|
||||||
|
item = @{ path = '/.trigger' }
|
||||||
|
newContent = @{ content = (Get-Date -Format 'yyyy-MM-dd HH:mm:ss'); contentType = 'rawtext' }
|
||||||
|
})
|
||||||
|
})
|
||||||
|
} | ConvertTo-Json -Depth 10
|
||||||
|
|
||||||
|
try {
|
||||||
|
$result = Invoke-RestMethod -Uri "$base/git/repositories/$id/pushes?api-version=7.0" -Method POST -Headers $h -Body $body -ErrorAction Stop
|
||||||
|
Write-Host " OK - commit: $($result.commits[0].commitId)" -ForegroundColor Green
|
||||||
|
} catch {
|
||||||
|
# Arquivo .trigger pode ja existir — tentar com edit
|
||||||
|
$body2 = @{
|
||||||
|
refUpdates = @(@{ name = 'refs/heads/devops'; oldObjectId = $oldSha })
|
||||||
|
commits = @(@{
|
||||||
|
comment = "ci: re-trigger pipeline apos correcao do template"
|
||||||
|
changes = @(@{
|
||||||
|
changeType = 'edit'
|
||||||
|
item = @{ path = '/.trigger' }
|
||||||
|
newContent = @{ content = (Get-Date -Format 'yyyy-MM-dd HH:mm:ss'); contentType = 'rawtext' }
|
||||||
|
})
|
||||||
|
})
|
||||||
|
} | ConvertTo-Json -Depth 10
|
||||||
|
try {
|
||||||
|
$result2 = Invoke-RestMethod -Uri "$base/git/repositories/$id/pushes?api-version=7.0" -Method POST -Headers $h -Body $body2 -ErrorAction Stop
|
||||||
|
Write-Host " OK (edit) - commit: $($result2.commits[0].commitId)" -ForegroundColor Green
|
||||||
|
} catch {
|
||||||
|
Write-Host " ERRO: $_" -ForegroundColor Red
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "Pipelines re-disparadas. Monitorando aprovacoes por 3 min..." -ForegroundColor Cyan
|
||||||
42
scripts/auto-organized/retrigger_mfe_shell.ps1
Normal file
42
scripts/auto-organized/retrigger_mfe_shell.ps1
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
$auth = Get-Content "$env:USERPROFILE\.ssh\azure_devops_auth.json" -Raw | ConvertFrom-Json
|
||||||
|
$PAT = $auth.pat
|
||||||
|
$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$PAT"))
|
||||||
|
$h = @{ Authorization = "Basic $t"; 'Content-Type' = 'application/json' }
|
||||||
|
$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis'
|
||||||
|
|
||||||
|
# Buscar repo mfe-shell
|
||||||
|
$repos = Invoke-RestMethod "$base/git/repositories?api-version=7.0" -Headers $h
|
||||||
|
$repo = $repos.value | Where-Object { $_.name -eq 'mfe-shell' } | Select-Object -First 1
|
||||||
|
if (-not $repo) { Write-Host "ERRO: repo mfe-shell nao encontrado"; exit 1 }
|
||||||
|
|
||||||
|
$repoId = $repo.id
|
||||||
|
Write-Host "Repo: $($repo.name) id=$repoId"
|
||||||
|
|
||||||
|
# Buscar branch devops
|
||||||
|
$branch = Invoke-RestMethod "$base/git/repositories/$repoId/refs?filter=heads/devops&api-version=7.0" -Headers $h
|
||||||
|
$sha = $branch.value[0].objectId
|
||||||
|
Write-Host "Branch devops: $sha"
|
||||||
|
|
||||||
|
# Verificar se .trigger-dns existe para usar edit ou add
|
||||||
|
$items = Invoke-RestMethod "$base/git/repositories/$repoId/items?path=/.trigger-dns&versionDescriptor.versionType=branch&versionDescriptor.version=devops&api-version=7.0" -Headers $h -ErrorAction SilentlyContinue
|
||||||
|
$changeType = if ($items -and $items.value) { 'edit' } else { 'add' }
|
||||||
|
Write-Host "Usando changeType: $changeType"
|
||||||
|
|
||||||
|
# Push trigger commit
|
||||||
|
$body = @{
|
||||||
|
refUpdates = @(@{ name = 'refs/heads/devops'; oldObjectId = $sha })
|
||||||
|
commits = @(@{
|
||||||
|
comment = 'chore: retrigger mfe-shell pipeline (dns oci subdomain)'
|
||||||
|
changes = @(@{
|
||||||
|
changeType = 'edit'
|
||||||
|
item = @{ path = '/.trigger-dns' }
|
||||||
|
newContent = @{ content = (Get-Date -Format 'yyyy-MM-dd HH:mm:ss'); contentType = 'rawtext' }
|
||||||
|
})
|
||||||
|
})
|
||||||
|
} | ConvertTo-Json -Depth 6
|
||||||
|
|
||||||
|
$push = Invoke-RestMethod "$base/git/repositories/$repoId/pushes?api-version=7.0" `
|
||||||
|
-Method POST -Headers $h -Body $body
|
||||||
|
|
||||||
|
Write-Host "Push ID: $($push.pushId) commit: $($push.commits[0].commitId)"
|
||||||
|
Write-Host "Pipeline sera triggerada automaticamente."
|
||||||
24
scripts/auto-organized/revert_cf_mfe_shell_dev.ps1
Normal file
24
scripts/auto-organized/revert_cf_mfe_shell_dev.ps1
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
$email = 'tiago.ribeiro@inventcloud.com.br'
|
||||||
|
$key = '7ae5565ab2dcdfdfdd66efb1105e27d18d186'
|
||||||
|
$h = @{ 'X-Auth-Email' = $email; 'X-Auth-Key' = $key; 'Content-Type' = 'application/json' }
|
||||||
|
|
||||||
|
$zoneId = '62cb52dc520cf3be1a685099c1e3887d'
|
||||||
|
$recordName = 'mfe-shell-dev.invista.com.br'
|
||||||
|
|
||||||
|
# Buscar records existentes
|
||||||
|
$existing = Invoke-RestMethod "https://api.cloudflare.com/client/v4/zones/$zoneId/dns_records?name=$recordName" -Headers $h
|
||||||
|
Write-Host "Records para $recordName`: $($existing.result.Count)"
|
||||||
|
$existing.result | ForEach-Object { Write-Host " $($_.id) $($_.type) -> $($_.content)" }
|
||||||
|
|
||||||
|
# Deletar o A record que criamos (136.248.66.216 = FortiGate)
|
||||||
|
foreach ($rec in $existing.result) {
|
||||||
|
if ($rec.content -eq '136.248.66.216') {
|
||||||
|
Write-Host "Deletando A record -> 136.248.66.216..."
|
||||||
|
$del = Invoke-RestMethod "https://api.cloudflare.com/client/v4/zones/$zoneId/dns_records/$($rec.id)" `
|
||||||
|
-Method DELETE -Headers $h
|
||||||
|
Write-Host "Deleted: $($del.success)"
|
||||||
|
} else {
|
||||||
|
Write-Host "Mantendo record: $($_.type) -> $($rec.content)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Write-Host "Concluido. mfe-shell-dev.invista.com.br revertido."
|
||||||
1
scripts/auto-organized/rsa_base64.txt
Normal file
1
scripts/auto-organized/rsa_base64.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
LS0tLS1CRUdJTiBQUklWQVRFIEtFWS0tLS0tCk1JSUV2UUlCQURBTkJna3Foa2lHOXcwQkFRRUZBQVNDQktjd2dnU2pBZ0VBQW9JQkFRQ2M5c3VEb2J3SndDR0oKVkZ2Z2ExQnhLa21tR094b0Y4ek5pYnY2bDMzL1NDRkVCYjVmRmFlbnh2WW90RUdXVXcwZmVkNHpJY1gzczZoQQpxMnlMcjNuSXlncExwY09menB6UHhhczQ5UDE3TkEzQ2h2bzNrLzBlR2tCRDZQSE0xczYycVBQK2ZLRVp0d2xTCnExV2FGeGZjOTQ5aXFKQVF2VzZ3LzdXZ01aRGluZXEzSXpoVlZVQUZkdzNpY1pydTk3aENqUERVL3YzZUZUUzcKa3ZHckRZR0FIWlh6eWx1M0VyOWlmS1lIZEt4T3JXRm1HYVNzUHNZTWRLTnhXRmsrWjM4TlZVbndTSDNURWlWLwpTNGUzM3RUa2RNbU5wWSs2ZTlDaWdiMDlSbk9hbGo1bFBqRkdBOW5USE1KeHBzSHZTS3U4dk1CcitPWjRDTTNVClJIN01VWDAxQWdNQkFBRUNnZ0VBTUt4ZEZvLzRNZVBZNG05ODRCNFcvMGlZTnYvaWl6TGFLT0J0b0xzS2NMZUsKelQra3RYS1BIemxVeXZGK3B5RlEzL0pZQTI0VktBY1hoUnBEV2h1TGZjYWRJN0VlOVBiS2JLbUV1M0JKREVQcgpnbWQ5dnU5T25kK1JEeDMwb1VyNUplNUZYeVNCaG1wYVl6N0xHREhTRGd6Y2MwRUhENUhXZWQrSmtFZmVnRTd3Ck12dDlLSzQxbUdkYVF3aVBIUzQzdXpaaFFKRXF5YlAzaS82U1VuVjJDbnRPaHV0eExsUGsycnBIbm5zMHAvU3QKRHZsY3Y2MXZkdUlhZWo0SUZCcnBTd1RFNDVwdklma3ZOWngwcEphcE0xalpoZThGLzJUN0d0WERrb0ZRdmVvMQozWUIxYWFkcEN4N3UyOEl6UVR3QlpWd3FoQ3BpMmE1K3FWWVVUMEFVM3dLQmdRRFlZVXhRVUJpVW42YlhvQXN4CkpUb3pvWDBLNTBjWDJkOExWWTFPVXVocFJYYnp0UzJYWHR5ZmVvQVF0RVdvVDNVTzd2akVlZFdzd2ZvMmorTjMKWklYaWc3VnlqL0xONWxaeUN3V1luNFM0aW5FU2pLbHppNFB2OEQ0RitGa2dnMFdzVmd6YlRhNFA3ZmFIbkRObgplRUhkeUovWlE4K1hZeEJwU0FFOGVjV1Fsd0tCZ1FDNXRHYmZ6aDc3UkVzdjFoNmI4N3Z1bHJHSGMrT0JJVFRVCllGdTFZZlhwdmJYeDlnZVJmTkxEdFVoVWlzNnZnZmNRVjZzeFpWZjc4VWRscWlUQmViUkxwY3ZvQmxIVi9NUFoKVDNUc1pIMXZYd2lpdE9zQklGektrbjh4ZGp1TjZtTjVsTGpJNktrWWVWb1VMWWlVTmJpWitXaTdQWEJQbmM1SQpqQk81RWF5T0V3S0JnUURVMnBuc28yNGF2aGF0SktYOTJXWXdwaHBRb0lTQ0JQUHh2VjM4LzNmYkh0ZE9GQnRlClBaWUFWOHdsSW9FbmVjcG9QMUorVEcrU3UxcjlVM3hxMVhzVEFZZDd3L2tRN1JaNnB6Y0JGV0xFK29NU3dVWnMKQUlGd2hiOHR0a2xPdjNQSmZQaTJ2dXFNaHdVdUQ4MU5hckk0andRWUFTbnovU0tHdnF0Z3AxVmV6d0tCZ0RvTApET3grL0dnRTNJdERIYVlZOUhDS1lVcTVDaTdlTmlqN1JTN1lRNGlmWnpNTmR5Z2VIN0pVQXh1Smx6aDhJc0RVCjVnazJaOTJ6ZUdGcVlMcW9VNVloYUM1SmEySzY4bXdGemNIbFZ0OXNrTUpxVWRtMFI4eDVKWkJNS0NrZlRhQSsKdjlMc0JZNUV2OGIyeEcydXJOaFRnRXlsMDJqUEpoNit5WnRhenRoSkFvR0FIUklYL1cwSWx5YUxubzdXekF3TQpsU3NOZkpwVHZabWtyaTBVT0dYTTJZYUt1UVo2NTJ0NkVCRHRmTTdPMTZlVjNLTkJibHQxTGpJdHovUzhraUZpClE4dEdsdU8yN0huNS9hdWl4SmpsY1puem9VWHJFakFyYThsbWdBbzQxRG0waWNEcExVemhpeFowcVM4ZDZZZnAKUklUMUlvV1N1dTJmdk9PdnFlenE2Ymc9Ci0tLS0tRU5EIFBSSVZBVEUgS0VZLS0tLS0K
|
||||||
341
scripts/auto-organized/start.sh
Normal file
341
scripts/auto-organized/start.sh
Normal file
|
|
@ -0,0 +1,341 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Colors
|
||||||
|
RED='\033[0;31m'
|
||||||
|
GREEN='\033[0;32m'
|
||||||
|
YELLOW='\033[1;33m'
|
||||||
|
BLUE='\033[0;34m'
|
||||||
|
CYAN='\033[0;36m'
|
||||||
|
NC='\033[0m' # No Color
|
||||||
|
|
||||||
|
# Function to kill background processes on exit
|
||||||
|
cleanup() {
|
||||||
|
echo -e "\n${YELLOW}🛑 Stopping services...${NC}"
|
||||||
|
kill $(jobs -p) 2>/dev/null
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
trap cleanup SIGINT SIGTERM
|
||||||
|
|
||||||
|
# Header
|
||||||
|
clear
|
||||||
|
echo -e "${CYAN}"
|
||||||
|
echo "╔══════════════════════════════════════════════╗"
|
||||||
|
echo "║ 🐴 GoHorse Jobs - Dev Server ║"
|
||||||
|
echo "╚══════════════════════════════════════════════╝"
|
||||||
|
echo -e "${NC}"
|
||||||
|
|
||||||
|
# Interactive menu
|
||||||
|
echo -e "${GREEN}Select an option:${NC}\n"
|
||||||
|
echo -e " ${CYAN}── Services ──${NC}"
|
||||||
|
echo -e " ${YELLOW}1)${NC} 🚀 Start (Frontend + Backend)"
|
||||||
|
echo -e " ${YELLOW}2)${NC} 🌱 Start with Seed (Reset DB + Seed + Start)"
|
||||||
|
echo -e " ${YELLOW}3)${NC} 📦 Start All (Frontend + Backend + Backoffice)"
|
||||||
|
echo -e ""
|
||||||
|
echo -e " ${CYAN}── Database ──${NC}"
|
||||||
|
echo -e " ${YELLOW}4)${NC} 🗄️ Run Migrations"
|
||||||
|
echo -e " ${YELLOW}5)${NC} 🌿 Seed Only (append data)"
|
||||||
|
echo -e " ${YELLOW}6)${NC} 🔄 Seed Reset (drop all + seed fresh)"
|
||||||
|
echo -e ""
|
||||||
|
echo -e " ${CYAN}── Testing ──${NC}"
|
||||||
|
echo -e " ${YELLOW}7)${NC} 🧪 Run Tests (Backend E2E)"
|
||||||
|
echo -e " ${YELLOW}0)${NC} ❌ Exit"
|
||||||
|
echo -e ""
|
||||||
|
echo -e " ${CYAN}── Fast Options ──${NC}"
|
||||||
|
echo -e " ${YELLOW}8)${NC} ⚡ Seed Reset LITE (skip 153k cities)"
|
||||||
|
echo -e " ${YELLOW}9)${NC} 🔬 Run All Tests (Backend + Frontend)"
|
||||||
|
echo -e ""
|
||||||
|
echo -e " ${CYAN}── Docker/Deploy ──${NC}"
|
||||||
|
echo -e " ${YELLOW}a)${NC} 🐳 Build Docker Images"
|
||||||
|
echo -e " ${YELLOW}b)${NC} 🚀 Build & Push to Forgejo"
|
||||||
|
echo ""
|
||||||
|
read -p "Enter option [0-9,a,b]: " choice
|
||||||
|
|
||||||
|
case $choice in
|
||||||
|
1)
|
||||||
|
echo -e "\n${GREEN}🚀 Starting Development Environment...${NC}\n"
|
||||||
|
|
||||||
|
# Backend
|
||||||
|
echo -e "${BLUE}🔹 Checking Backend...${NC}"
|
||||||
|
cd backend && go mod tidy
|
||||||
|
if command -v swag &> /dev/null; then
|
||||||
|
echo -e "${BLUE}🔹 Generating Swagger Docs...${NC}"
|
||||||
|
swag init -g cmd/api/main.go --parseDependency --parseInternal 2>/dev/null
|
||||||
|
fi
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
# Frontend deps
|
||||||
|
if [ ! -d "frontend/node_modules" ]; then
|
||||||
|
echo -e "${BLUE}🔹 Installing Frontend Dependencies...${NC}"
|
||||||
|
cd frontend && npm install && cd ..
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Start services
|
||||||
|
echo -e "${BLUE}🔹 Starting Backend on port 8521...${NC}"
|
||||||
|
(cd backend && go run cmd/api/main.go) &
|
||||||
|
BACKEND_PID=$!
|
||||||
|
sleep 2
|
||||||
|
|
||||||
|
echo -e "${BLUE}🔹 Starting Frontend on port 8963...${NC}"
|
||||||
|
(cd frontend && npm run dev -- -p 8963) &
|
||||||
|
FRONTEND_PID=$!
|
||||||
|
|
||||||
|
echo -e "\n${GREEN}✅ Services running:${NC}"
|
||||||
|
echo -e " ${CYAN}Backend:${NC} http://localhost:8521"
|
||||||
|
echo -e " ${CYAN}Frontend:${NC} http://localhost:8963"
|
||||||
|
echo -e " ${CYAN}Swagger:${NC} http://localhost:8521/swagger/index.html"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
wait $BACKEND_PID $FRONTEND_PID
|
||||||
|
;;
|
||||||
|
|
||||||
|
2)
|
||||||
|
echo -e "\n${GREEN}🌱 Starting with Database Reset & Seed...${NC}\n"
|
||||||
|
|
||||||
|
# Backend prep
|
||||||
|
echo -e "${BLUE}🔹 Checking Backend...${NC}"
|
||||||
|
cd backend && go mod tidy
|
||||||
|
if command -v swag &> /dev/null; then
|
||||||
|
swag init -g cmd/api/main.go --parseDependency --parseInternal 2>/dev/null
|
||||||
|
fi
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
# Seeder deps
|
||||||
|
cd seeder-api
|
||||||
|
if [ ! -d "node_modules" ]; then
|
||||||
|
echo -e "${BLUE}🔹 Installing Seeder Dependencies...${NC}"
|
||||||
|
npm install
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "${YELLOW}🔹 Resetting Database...${NC}"
|
||||||
|
npm run seed:reset
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
# Start backend
|
||||||
|
echo -e "${BLUE}🔹 Starting Backend...${NC}"
|
||||||
|
(cd backend && go run cmd/api/main.go) &
|
||||||
|
BACKEND_PID=$!
|
||||||
|
|
||||||
|
echo -e "${YELLOW}⏳ Waiting for Backend...${NC}"
|
||||||
|
sleep 5
|
||||||
|
|
||||||
|
# Seed
|
||||||
|
echo -e "${BLUE}🔹 Seeding Database (30 companies, 990 jobs)...${NC}"
|
||||||
|
cd seeder-api && npm run seed && cd ..
|
||||||
|
|
||||||
|
# Frontend
|
||||||
|
if [ ! -d "frontend/node_modules" ]; then
|
||||||
|
cd frontend && npm install && cd ..
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "${BLUE}🔹 Starting Frontend...${NC}"
|
||||||
|
(cd frontend && npm run dev -- -p 8963) &
|
||||||
|
FRONTEND_PID=$!
|
||||||
|
|
||||||
|
echo -e "\n${GREEN}✅ Services running with fresh data!${NC}"
|
||||||
|
echo -e " ${CYAN}Backend:${NC} http://localhost:8521"
|
||||||
|
echo -e " ${CYAN}Frontend:${NC} http://localhost:8963"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
wait $BACKEND_PID $FRONTEND_PID
|
||||||
|
;;
|
||||||
|
|
||||||
|
3)
|
||||||
|
echo -e "\n${GREEN}📦 Starting All Services (Including Backoffice)...${NC}\n"
|
||||||
|
|
||||||
|
# Backend
|
||||||
|
cd backend && go mod tidy && cd ..
|
||||||
|
|
||||||
|
# Dependencies
|
||||||
|
[ ! -d "frontend/node_modules" ] && (cd frontend && npm install && cd ..)
|
||||||
|
[ ! -d "backoffice/node_modules" ] && (cd backoffice && npm install && cd ..)
|
||||||
|
|
||||||
|
echo -e "${BLUE}🔹 Starting Backend on port 8521...${NC}"
|
||||||
|
(cd backend && go run cmd/api/main.go) &
|
||||||
|
sleep 2
|
||||||
|
|
||||||
|
echo -e "${BLUE}🔹 Starting Frontend on port 8963...${NC}"
|
||||||
|
(cd frontend && npm run dev -- -p 8963) &
|
||||||
|
|
||||||
|
echo -e "${BLUE}🔹 Starting Backoffice on port 3001...${NC}"
|
||||||
|
(cd backoffice && npm run start:dev) &
|
||||||
|
|
||||||
|
echo -e "\n${GREEN}✅ All services running:${NC}"
|
||||||
|
echo -e " ${CYAN}Backend:${NC} http://localhost:8521"
|
||||||
|
echo -e " ${CYAN}Frontend:${NC} http://localhost:8963"
|
||||||
|
echo -e " ${CYAN}Backoffice:${NC} http://localhost:3001"
|
||||||
|
echo -e " ${CYAN}Swagger:${NC} http://localhost:3001/api/docs"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
wait
|
||||||
|
;;
|
||||||
|
|
||||||
|
4)
|
||||||
|
echo -e "\n${GREEN}🗄️ Running Migrations...${NC}\n"
|
||||||
|
cd seeder-api
|
||||||
|
[ ! -d "node_modules" ] && npm install
|
||||||
|
npm run migrate
|
||||||
|
;;
|
||||||
|
|
||||||
|
5)
|
||||||
|
echo -e "\n${GREEN}🌿 Seeding Database Only...${NC}\n"
|
||||||
|
cd seeder-api
|
||||||
|
[ ! -d "node_modules" ] && npm install
|
||||||
|
npm run seed
|
||||||
|
echo -e "\n${GREEN}✅ Seeding completed!${NC}"
|
||||||
|
;;
|
||||||
|
|
||||||
|
6)
|
||||||
|
echo -e "\n${GREEN}🔄 Resetting Database & Seeding Fresh...${NC}\n"
|
||||||
|
cd seeder-api
|
||||||
|
[ ! -d "node_modules" ] && npm install
|
||||||
|
|
||||||
|
echo -e "${YELLOW}⚠️ This will DROP all tables and recreate!${NC}"
|
||||||
|
read -p "Are you sure? [y/N]: " confirm
|
||||||
|
|
||||||
|
if [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]]; then
|
||||||
|
echo -e "\n${BLUE}🔹 Step 1/3: Dropping all tables...${NC}"
|
||||||
|
npm run seed:reset
|
||||||
|
|
||||||
|
echo -e "\n${BLUE}🔹 Step 2/3: Running migrations...${NC}"
|
||||||
|
npm run migrate
|
||||||
|
|
||||||
|
echo -e "\n${BLUE}🔹 Step 3/3: Seeding data...${NC}"
|
||||||
|
npm run seed
|
||||||
|
|
||||||
|
echo -e "\n${GREEN}✅ Database fully reset and seeded!${NC}"
|
||||||
|
else
|
||||||
|
echo -e "${YELLOW}Cancelled.${NC}"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
|
7)
|
||||||
|
echo -e "\n${GREEN}🧪 Running Backend E2E Tests...${NC}\n"
|
||||||
|
cd backend && go test -tags=e2e -v ./tests/e2e/... 2>&1
|
||||||
|
echo -e "\n${GREEN}✅ Tests completed!${NC}"
|
||||||
|
;;
|
||||||
|
|
||||||
|
8)
|
||||||
|
echo -e "\n${GREEN}⚡ Fast Reset - Seed LITE (no cities)...${NC}\n"
|
||||||
|
cd seeder-api
|
||||||
|
[ ! -d "node_modules" ] && npm install
|
||||||
|
|
||||||
|
echo -e "${YELLOW}⚠️ This will DROP all tables and recreate (WITHOUT 153k cities)${NC}"
|
||||||
|
read -p "Are you sure? [y/N]: " confirm
|
||||||
|
|
||||||
|
if [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]]; then
|
||||||
|
echo -e "\n${BLUE}🔹 Step 1/3: Dropping all tables...${NC}"
|
||||||
|
npm run seed:reset
|
||||||
|
|
||||||
|
echo -e "\n${BLUE}🔹 Step 2/3: Running migrations...${NC}"
|
||||||
|
npm run migrate
|
||||||
|
|
||||||
|
echo -e "\n${BLUE}🔹 Step 3/3: Seeding data (LITE - no cities)...${NC}"
|
||||||
|
npm run seed:lite
|
||||||
|
|
||||||
|
echo -e "\n${GREEN}✅ Database reset (LITE) completed! Cities skipped for speed.${NC}"
|
||||||
|
else
|
||||||
|
echo -e "${YELLOW}Cancelled.${NC}"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
|
9)
|
||||||
|
echo -e "\n${GREEN}🔬 Running All Tests...${NC}\n"
|
||||||
|
|
||||||
|
echo -e "${BLUE}🔹 Backend Unit Tests...${NC}"
|
||||||
|
cd backend && go test -v ./... -count=1 2>&1 | tail -20
|
||||||
|
BACKEND_RESULT=$?
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
echo -e "\n${BLUE}🔹 Backend E2E Tests...${NC}"
|
||||||
|
cd backend && go test -tags=e2e -v ./tests/e2e/... 2>&1
|
||||||
|
E2E_RESULT=$?
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
if [ -d "frontend/node_modules" ]; then
|
||||||
|
echo -e "\n${BLUE}🔹 Frontend Tests...${NC}"
|
||||||
|
cd frontend && npm test -- --passWithNoTests 2>&1
|
||||||
|
FRONTEND_RESULT=$?
|
||||||
|
cd ..
|
||||||
|
else
|
||||||
|
echo -e "${YELLOW}⚠️ Frontend node_modules not found, skipping frontend tests${NC}"
|
||||||
|
FRONTEND_RESULT=0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "\n${GREEN}═══════════════════════════════════════${NC}"
|
||||||
|
if [ $BACKEND_RESULT -eq 0 ] && [ $E2E_RESULT -eq 0 ] && [ $FRONTEND_RESULT -eq 0 ]; then
|
||||||
|
echo -e "${GREEN}✅ All tests passed!${NC}"
|
||||||
|
else
|
||||||
|
echo -e "${RED}❌ Some tests failed${NC}"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
|
0)
|
||||||
|
echo -e "${YELLOW}Bye! 👋${NC}"
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
echo -e "${RED}Invalid option. Exiting.${NC}"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
|
||||||
|
a)
|
||||||
|
echo -e "\n${GREEN}🐳 Building Docker Images...${NC}\n"
|
||||||
|
|
||||||
|
REGISTRY="forgejo-gru.rede5.com.br/rede5"
|
||||||
|
|
||||||
|
echo -e "${BLUE}🔹 Building Backend...${NC}"
|
||||||
|
podman build -t $REGISTRY/gohorsejobs-backend:latest -f backend/Dockerfile backend/
|
||||||
|
|
||||||
|
echo -e "\n${BLUE}🔹 Building Frontend...${NC}"
|
||||||
|
podman build -t $REGISTRY/gohorsejobs-frontend:latest -f frontend/Dockerfile frontend/
|
||||||
|
|
||||||
|
echo -e "\n${BLUE}🔹 Building Seeder...${NC}"
|
||||||
|
podman build -t $REGISTRY/gohorsejobs-seeder:latest -f seeder-api/Dockerfile seeder-api/
|
||||||
|
|
||||||
|
echo -e "\n${GREEN}✅ All images built successfully!${NC}"
|
||||||
|
echo -e " ${CYAN}Backend:${NC} $REGISTRY/gohorsejobs-backend:latest"
|
||||||
|
echo -e " ${CYAN}Frontend:${NC} $REGISTRY/gohorsejobs-frontend:latest"
|
||||||
|
echo -e " ${CYAN}Seeder:${NC} $REGISTRY/gohorsejobs-seeder:latest"
|
||||||
|
;;
|
||||||
|
|
||||||
|
b)
|
||||||
|
echo -e "\n${GREEN}🚀 Building & Pushing to Forgejo Registry...${NC}\n"
|
||||||
|
|
||||||
|
REGISTRY="forgejo-gru.rede5.com.br/rede5"
|
||||||
|
|
||||||
|
# Check if logged in
|
||||||
|
echo -e "${BLUE}🔹 Checking registry login...${NC}"
|
||||||
|
if ! podman login --get-login $REGISTRY 2>/dev/null; then
|
||||||
|
echo -e "${YELLOW}⚠️ Not logged in. Please enter your credentials:${NC}"
|
||||||
|
read -p "Username: " REGISTRY_USER
|
||||||
|
read -s -p "Password/Token: " REGISTRY_PASS
|
||||||
|
echo ""
|
||||||
|
podman login forgejo-gru.rede5.com.br -u "$REGISTRY_USER" -p "$REGISTRY_PASS"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "\n${BLUE}🔹 Building Backend...${NC}"
|
||||||
|
podman build -t $REGISTRY/gohorsejobs-backend:latest -f backend/Dockerfile backend/
|
||||||
|
|
||||||
|
echo -e "\n${BLUE}🔹 Building Frontend...${NC}"
|
||||||
|
podman build -t $REGISTRY/gohorsejobs-frontend:latest -f frontend/Dockerfile frontend/
|
||||||
|
|
||||||
|
echo -e "\n${BLUE}🔹 Building Seeder...${NC}"
|
||||||
|
podman build -t $REGISTRY/gohorsejobs-seeder:latest -f seeder-api/Dockerfile seeder-api/
|
||||||
|
|
||||||
|
echo -e "\n${BLUE}🔹 Pushing Backend...${NC}"
|
||||||
|
podman push $REGISTRY/gohorsejobs-backend:latest
|
||||||
|
|
||||||
|
echo -e "\n${BLUE}🔹 Pushing Frontend...${NC}"
|
||||||
|
podman push $REGISTRY/gohorsejobs-frontend:latest
|
||||||
|
|
||||||
|
echo -e "\n${BLUE}🔹 Pushing Seeder...${NC}"
|
||||||
|
podman push $REGISTRY/gohorsejobs-seeder:latest
|
||||||
|
|
||||||
|
echo -e "\n${GREEN}✅ All images built and pushed!${NC}"
|
||||||
|
echo -e " ${CYAN}Registry:${NC} $REGISTRY"
|
||||||
|
echo -e " ${CYAN}Images:${NC} gohorsejobs-backend, gohorsejobs-frontend, gohorsejobs-seeder"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
20
scripts/auto-organized/verify_vg.ps1
Normal file
20
scripts/auto-organized/verify_vg.ps1
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp'
|
||||||
|
$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p))
|
||||||
|
$h = @{ Authorization = 'Basic ' + $t; 'Content-Type' = 'application/json' }
|
||||||
|
$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis'
|
||||||
|
|
||||||
|
# Verificar oci-terraform
|
||||||
|
$vg = Invoke-RestMethod -Uri "$base/distributedtask/variablegroups/34?api-version=7.0" -Headers $h
|
||||||
|
Write-Host "=== oci-terraform ===" -ForegroundColor Cyan
|
||||||
|
$vg.variables.PSObject.Properties | ForEach-Object {
|
||||||
|
$val = if ($_.Value.isSecret) { '(secret)' } else { $_.Value.value }
|
||||||
|
Write-Host " $($_.Name) = $val"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Verificar ms-parameters-dev
|
||||||
|
$vg40 = Invoke-RestMethod -Uri "$base/distributedtask/variablegroups/40?api-version=7.0" -Headers $h
|
||||||
|
Write-Host "`n=== ms-parameters-dev (ID: 40) ===" -ForegroundColor Cyan
|
||||||
|
$vg40.variables.PSObject.Properties | ForEach-Object {
|
||||||
|
$val = if ($_.Value.isSecret) { '(secret)' } else { $_.Value.value }
|
||||||
|
Write-Host " $($_.Name) = $val"
|
||||||
|
}
|
||||||
135
scripts/auto-organized/vw_full.json
Normal file
135
scripts/auto-organized/vw_full.json
Normal file
|
|
@ -0,0 +1,135 @@
|
||||||
|
{
|
||||||
|
"uuid": "h8wg0gogw44swosgk8wgc8cs",
|
||||||
|
"description": "Cofre de senhas",
|
||||||
|
"name": "Vaultwarden",
|
||||||
|
"applications": [
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"uuid": "xokg0wk40og0kgg4088o084o",
|
||||||
|
"name": "vaultwarden",
|
||||||
|
"human_name": null,
|
||||||
|
"description": null,
|
||||||
|
"fqdn": "https://vault.rede5.com.br",
|
||||||
|
"ports": "",
|
||||||
|
"exposes": null,
|
||||||
|
"status": "running:healthy",
|
||||||
|
"service_id": 2,
|
||||||
|
"created_at": "2026-02-16T17:53:04.000000Z",
|
||||||
|
"updated_at": "2026-02-23T14:12:07.000000Z",
|
||||||
|
"exclude_from_status": false,
|
||||||
|
"required_fqdn": false,
|
||||||
|
"image": "vaultwarden/server:latest",
|
||||||
|
"is_log_drain_enabled": false,
|
||||||
|
"is_include_timestamps": false,
|
||||||
|
"deleted_at": null,
|
||||||
|
"is_gzip_enabled": true,
|
||||||
|
"is_stripprefix_enabled": true,
|
||||||
|
"last_online_at": "2026-02-23 14:12:07",
|
||||||
|
"is_migrated": false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"compose_parsing_version": "5",
|
||||||
|
"config_hash": "3035632fa8e7d4156c09f4bb8d048033",
|
||||||
|
"connect_to_docker_network": false,
|
||||||
|
"databases": [
|
||||||
|
|
||||||
|
],
|
||||||
|
"deleted_at": null,
|
||||||
|
"destination_id": 0,
|
||||||
|
"destination_type": "App\\Models\\StandaloneDocker",
|
||||||
|
"docker_compose": "services:\n vaultwarden:\n image: \u0027vaultwarden/server:latest\u0027\n environment:\n DOMAIN: \u0027${SERVICE_URL_VAULTWARDEN}\u0027\n DATABASE_URL: \u0027${VAULTWARDEN_DB_URL:-data/db.sqlite3}\u0027\n SIGNUPS_ALLOWED: \u0027${SIGNUP_ALLOWED:-true}\u0027\n ADMIN_TOKEN: \u0027${SERVICE_PASSWORD_64_ADMIN}\u0027\n IP_HEADER: X-Forwarded-For\n PUSH_ENABLED: \u0027${PUSH_ENABLED:-false}\u0027\n PUSH_INSTALLATION_ID: \u0027${PUSH_SERVICE_ID}\u0027\n PUSH_INSTALLATION_KEY: \u0027${PUSH_SERVICE_KEY}\u0027\n PUSH_SERVICE_ID: \u0027${PUSH_SERVICE_ID}\u0027\n PUSH_SERVICE_KEY: \u0027${PUSH_SERVICE_KEY}\u0027\n COOLIFY_RESOURCE_UUID: h8wg0gogw44swosgk8wgc8cs\n COOLIFY_CONTAINER_NAME: vaultwarden-h8wg0gogw44swosgk8wgc8cs\n COOLIFY_FQDN: vault.rede5.com.br\n COOLIFY_URL: \u0027https://vault.rede5.com.br\u0027\n SERVICE_NAME_VAULTWARDEN: vaultwarden\n volumes:\n - \u0027h8wg0gogw44swosgk8wgc8cs_vaultwarden-data:/data\u0027\n healthcheck:\n test:\n - CMD\n - curl\n - \u0027-f\u0027\n - \u0027http://127.0.0.1:80\u0027\n interval: 2s\n timeout: 10s\n retries: 15\n container_name: vaultwarden-h8wg0gogw44swosgk8wgc8cs\n restart: unless-stopped\n labels:\n - coolify.managed=true\n - coolify.version=4.0.0-beta.463\n - coolify.serviceId=2\n - coolify.type=service\n - coolify.name=vaultwarden-h8wg0gogw44swosgk8wgc8cs\n - coolify.resourceName=vaultwarden\n - coolify.projectName=infraestrutura\n - coolify.serviceName=vaultwarden\n - coolify.environmentName=production\n - coolify.pullRequestId=0\n - coolify.service.subId=2\n - coolify.service.subType=application\n - coolify.service.subName=vaultwarden\n - traefik.enable=true\n - traefik.http.middlewares.gzip.compress=true\n - traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https\n - traefik.http.routers.http-0-h8wg0gogw44swosgk8wgc8cs-vaultwarden.entryPoints=http\n - traefik.http.routers.http-0-h8wg0gogw44swosgk8wgc8cs-vaultwarden.middlewares=redirect-to-https\n - \u0027traefik.http.routers.http-0-h8wg0gogw44swosgk8wgc8cs-vaultwarden.rule=Host(`vault.rede5.com.br`) \u0026\u0026 PathPrefix(`/`)\u0027\n - traefik.http.routers.https-0-h8wg0gogw44swosgk8wgc8cs-vaultwarden.entryPoints=https\n - traefik.http.routers.https-0-h8wg0gogw44swosgk8wgc8cs-vaultwarden.middlewares=gzip\n - \u0027traefik.http.routers.https-0-h8wg0gogw44swosgk8wgc8cs-vaultwarden.rule=Host(`vault.rede5.com.br`) \u0026\u0026 PathPrefix(`/`)\u0027\n - traefik.http.routers.https-0-h8wg0gogw44swosgk8wgc8cs-vaultwarden.tls.certresolver=letsencrypt\n - traefik.http.routers.https-0-h8wg0gogw44swosgk8wgc8cs-vaultwarden.tls=true\n - \u0027caddy_0.encode=zstd gzip\u0027\n - \u0027caddy_0.handle_path.0_reverse_proxy={{upstreams 80}}\u0027\n - \u0027caddy_0.handle_path=/*\u0027\n - caddy_0.header=-Server\n - \u0027caddy_0.try_files={path} /index.html /index.php\u0027\n - \u0027caddy_0=https://vault.rede5.com.br\u0027\n - caddy_ingress_network=h8wg0gogw44swosgk8wgc8cs\n networks:\n h8wg0gogw44swosgk8wgc8cs: null\n env_file:\n - .env\nvolumes:\n h8wg0gogw44swosgk8wgc8cs_vaultwarden-data:\n name: h8wg0gogw44swosgk8wgc8cs_vaultwarden-data\nnetworks:\n h8wg0gogw44swosgk8wgc8cs:\n name: h8wg0gogw44swosgk8wgc8cs\n external: true\n",
|
||||||
|
"docker_compose_raw": "services:\n vaultwarden:\n image: \u0027vaultwarden/server:latest\u0027\n environment:\n - \u0027SERVICE_FQDN_VAULTWARDEN_HTTPS=https://vault.rede5.com.br\u0027\n - \u0027SERVICE_FQDN_VAULTWARDEN=https://vault.rede5.com.br\u0027\n - \u0027DOMAIN=${SERVICE_URL_VAULTWARDEN}\u0027\n - \u0027DATABASE_URL=${VAULTWARDEN_DB_URL:-data/db.sqlite3}\u0027\n - \u0027SIGNUPS_ALLOWED=${SIGNUP_ALLOWED:-true}\u0027\n - \u0027ADMIN_TOKEN=${SERVICE_PASSWORD_64_ADMIN}\u0027\n - IP_HEADER=X-Forwarded-For\n - \u0027PUSH_ENABLED=${PUSH_ENABLED:-false}\u0027\n - \u0027PUSH_INSTALLATION_ID=${PUSH_SERVICE_ID}\u0027\n - \u0027PUSH_INSTALLATION_KEY=${PUSH_SERVICE_KEY}\u0027\n volumes:\n - \u0027vaultwarden-data:/data\u0027\n healthcheck:\n test:\n - CMD\n - curl\n - \u0027-f\u0027\n - \u0027http://127.0.0.1:80\u0027\n interval: 2s\n timeout: 10s\n retries: 15\n",
|
||||||
|
"environment_id": 1,
|
||||||
|
"is_container_label_escape_enabled": true,
|
||||||
|
"server": {
|
||||||
|
"id": 0,
|
||||||
|
"uuid": "m844o4gkwkwcc0k48swgs8c8",
|
||||||
|
"name": "localhost",
|
||||||
|
"description": "This is the server where Coolify is running on. Don\u0027t delete this!",
|
||||||
|
"ip": "host.docker.internal",
|
||||||
|
"port": 22,
|
||||||
|
"user": "root",
|
||||||
|
"team_id": 0,
|
||||||
|
"private_key_id": 0,
|
||||||
|
"proxy": {
|
||||||
|
"type": "TRAEFIK",
|
||||||
|
"status": "running",
|
||||||
|
"last_saved_settings": null,
|
||||||
|
"last_applied_settings": null,
|
||||||
|
"redirect_enabled": true,
|
||||||
|
"force_stop": false
|
||||||
|
},
|
||||||
|
"created_at": "2026-02-16T12:39:11.000000Z",
|
||||||
|
"updated_at": "2026-02-23T15:04:09.000000Z",
|
||||||
|
"unreachable_notification_sent": false,
|
||||||
|
"unreachable_count": 0,
|
||||||
|
"high_disk_usage_notification_sent": false,
|
||||||
|
"log_drain_notification_sent": false,
|
||||||
|
"swarm_cluster": null,
|
||||||
|
"validation_logs": null,
|
||||||
|
"sentinel_updated_at": "2026-02-23 15:04:09",
|
||||||
|
"deleted_at": null,
|
||||||
|
"ip_previous": null,
|
||||||
|
"hetzner_server_id": null,
|
||||||
|
"cloud_provider_token_id": null,
|
||||||
|
"hetzner_server_status": null,
|
||||||
|
"is_validating": false,
|
||||||
|
"detected_traefik_version": "3.6.8",
|
||||||
|
"traefik_outdated_info": null,
|
||||||
|
"is_coolify_host": true,
|
||||||
|
"settings": {
|
||||||
|
"id": 1,
|
||||||
|
"is_swarm_manager": false,
|
||||||
|
"is_jump_server": false,
|
||||||
|
"is_build_server": false,
|
||||||
|
"is_reachable": true,
|
||||||
|
"is_usable": true,
|
||||||
|
"server_id": 0,
|
||||||
|
"created_at": "2026-02-16T12:39:11.000000Z",
|
||||||
|
"updated_at": "2026-02-16T12:47:49.000000Z",
|
||||||
|
"wildcard_domain": null,
|
||||||
|
"is_cloudflare_tunnel": false,
|
||||||
|
"is_logdrain_newrelic_enabled": false,
|
||||||
|
"logdrain_newrelic_license_key": null,
|
||||||
|
"logdrain_newrelic_base_uri": null,
|
||||||
|
"is_logdrain_highlight_enabled": false,
|
||||||
|
"logdrain_highlight_project_id": null,
|
||||||
|
"is_logdrain_axiom_enabled": false,
|
||||||
|
"logdrain_axiom_dataset_name": null,
|
||||||
|
"logdrain_axiom_api_key": null,
|
||||||
|
"is_swarm_worker": false,
|
||||||
|
"is_logdrain_custom_enabled": false,
|
||||||
|
"logdrain_custom_config": null,
|
||||||
|
"logdrain_custom_config_parser": null,
|
||||||
|
"concurrent_builds": 2,
|
||||||
|
"dynamic_timeout": 3600,
|
||||||
|
"force_disabled": false,
|
||||||
|
"is_metrics_enabled": false,
|
||||||
|
"generate_exact_labels": false,
|
||||||
|
"force_docker_cleanup": true,
|
||||||
|
"docker_cleanup_frequency": "0 0 * * *",
|
||||||
|
"docker_cleanup_threshold": 80,
|
||||||
|
"server_timezone": "UTC",
|
||||||
|
"delete_unused_volumes": false,
|
||||||
|
"delete_unused_networks": false,
|
||||||
|
"is_sentinel_enabled": true,
|
||||||
|
"sentinel_token": "eyJpdiI6IlpzSVdrV0p2UktKY1N3VGpDUm4yQXc9PSIsInZhbHVlIjoiTC9KS3ppK3FYeWJCa1dzYXZOWDFFWHErdkhXWkVFT1ZRNHdNTVVacHVHS3M0UkJHS2JzZUtZbHFtNW16ZGlzV3plRlUzVWQ5WFRVQm1IdW1ETWdSTnc9PSIsIm1hYyI6IjRkNjgzMzU2MWE1YWExYjE2MTkyNDM3ZDg2MTNmODYxNWY1Mzk5YjEwM2EwNWY5YjIyNTk5MDJkNGY2NGU2NjkiLCJ0YWciOiIifQ==",
|
||||||
|
"sentinel_metrics_refresh_rate_seconds": 10,
|
||||||
|
"sentinel_metrics_history_days": 7,
|
||||||
|
"sentinel_push_interval_seconds": 60,
|
||||||
|
"sentinel_custom_url": "http://host.docker.internal:8000",
|
||||||
|
"server_disk_usage_notification_threshold": 80,
|
||||||
|
"is_sentinel_debug_enabled": false,
|
||||||
|
"server_disk_usage_check_frequency": "0 23 * * *",
|
||||||
|
"is_terminal_enabled": true,
|
||||||
|
"deployment_queue_limit": 25,
|
||||||
|
"disable_application_image_retention": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"server_id": 0,
|
||||||
|
"server_status": true,
|
||||||
|
"service_type": null,
|
||||||
|
"status": "running:healthy",
|
||||||
|
"created_at": "2026-02-16T17:53:04.000000Z",
|
||||||
|
"updated_at": "2026-02-17T21:39:21.000000Z"
|
||||||
|
}
|
||||||
48
scripts/auto-organized/wait_builds.ps1
Normal file
48
scripts/auto-organized/wait_builds.ps1
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp'
|
||||||
|
$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p))
|
||||||
|
$h = @{ Authorization = 'Basic ' + $t }
|
||||||
|
$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis'
|
||||||
|
|
||||||
|
$buildIds = @(6181, 6182, 6183, 6185, 6186) # mfe-shell, mfe-auth, mfe-shell-oci, mfe-person, mfe-poc
|
||||||
|
# mfe-user nao apareceu, buscar separado
|
||||||
|
$defs = Invoke-RestMethod -Uri "$base/build/definitions?name=mfe-user&api-version=7.0" -Headers $h
|
||||||
|
if ($defs.count -gt 0) {
|
||||||
|
$defId = $defs.value[0].id
|
||||||
|
$ub = Invoke-RestMethod -Uri "$base/build/builds?definitions=$defId&branchName=refs/heads/devops&`$top=1&api-version=7.0" -Headers $h
|
||||||
|
if ($ub.count -gt 0) { $buildIds += $ub.value[0].id }
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "Aguardando builds: $($buildIds -join ', ')" -ForegroundColor Cyan
|
||||||
|
|
||||||
|
for ($i = 0; $i -lt 30; $i++) {
|
||||||
|
Start-Sleep -Seconds 15
|
||||||
|
$ts = Get-Date -Format 'HH:mm:ss'
|
||||||
|
$pending = 0
|
||||||
|
$status = @()
|
||||||
|
|
||||||
|
foreach ($bid in $buildIds) {
|
||||||
|
$b = Invoke-RestMethod -Uri "$base/build/builds/$bid`?api-version=7.0" -Headers $h
|
||||||
|
$result = if ($b.result) { $b.result } else { '...' }
|
||||||
|
$status += "$($b.definition.name)=$result"
|
||||||
|
if ($b.status -ne 'completed') { $pending++ }
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "$ts $($status -join ' ')"
|
||||||
|
if ($pending -eq 0) { break }
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "Resumo final:" -ForegroundColor Cyan
|
||||||
|
foreach ($bid in $buildIds) {
|
||||||
|
$b = Invoke-RestMethod -Uri "$base/build/builds/$bid`?api-version=7.0" -Headers $h
|
||||||
|
$result = if ($b.result) { $b.result } else { $b.status }
|
||||||
|
$icon = if ($result -eq 'succeeded') { 'OK' } else { 'FALHOU' }
|
||||||
|
Write-Host " [$icon] $($b.definition.name) (build $bid): $result"
|
||||||
|
|
||||||
|
if ($result -eq 'failed') {
|
||||||
|
$vr = $b.validationResults
|
||||||
|
if ($vr) {
|
||||||
|
$vr | Select-Object -First 2 | ForEach-Object { Write-Host " erro: $($_.message)" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
48
scripts/auto-organized/wait_builds2.ps1
Normal file
48
scripts/auto-organized/wait_builds2.ps1
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp'
|
||||||
|
$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p))
|
||||||
|
$h = @{ Authorization = 'Basic ' + $t }
|
||||||
|
$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis'
|
||||||
|
|
||||||
|
$buildIds = @(6181, 6182, 6183, 6185, 6186) # mfe-shell, mfe-auth, mfe-shell-oci, mfe-person, mfe-poc
|
||||||
|
# mfe-user nao apareceu, buscar separado
|
||||||
|
$defs = Invoke-RestMethod -Uri "$base/build/definitions?name=mfe-user&api-version=7.0" -Headers $h
|
||||||
|
if ($defs.count -gt 0) {
|
||||||
|
$defId = $defs.value[0].id
|
||||||
|
$ub = Invoke-RestMethod -Uri "$base/build/builds?definitions=$defId&branchName=refs/heads/devops&`$top=1&api-version=7.0" -Headers $h
|
||||||
|
if ($ub.count -gt 0) { $buildIds += $ub.value[0].id }
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "Aguardando builds: $($buildIds -join ', ')" -ForegroundColor Cyan
|
||||||
|
|
||||||
|
for ($i = 0; $i -lt 30; $i++) {
|
||||||
|
Start-Sleep -Seconds 15
|
||||||
|
$ts = Get-Date -Format 'HH:mm:ss'
|
||||||
|
$pending = 0
|
||||||
|
$status = @()
|
||||||
|
|
||||||
|
foreach ($bid in $buildIds) {
|
||||||
|
$b = Invoke-RestMethod -Uri "$base/build/builds/$bid`?api-version=7.0" -Headers $h
|
||||||
|
$result = if ($b.result) { $b.result } else { '...' }
|
||||||
|
$status += "$($b.definition.name)=$result"
|
||||||
|
if ($b.status -ne 'completed') { $pending++ }
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "$ts $($status -join ' ')"
|
||||||
|
if ($pending -eq 0) { break }
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "Resumo final:" -ForegroundColor Cyan
|
||||||
|
foreach ($bid in $buildIds) {
|
||||||
|
$b = Invoke-RestMethod -Uri "$base/build/builds/$bid`?api-version=7.0" -Headers $h
|
||||||
|
$result = if ($b.result) { $b.result } else { $b.status }
|
||||||
|
$icon = if ($result -eq 'succeeded') { 'OK' } else { 'FALHOU' }
|
||||||
|
Write-Host " [$icon] $($b.definition.name) (build $bid): $result"
|
||||||
|
|
||||||
|
if ($result -eq 'failed') {
|
||||||
|
$vr = $b.validationResults
|
||||||
|
if ($vr) {
|
||||||
|
$vr | Select-Object -First 2 | ForEach-Object { Write-Host " erro: $($_.message)" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
35
scripts/auto-organized/watch_approvals.ps1
Normal file
35
scripts/auto-organized/watch_approvals.ps1
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp'
|
||||||
|
$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p))
|
||||||
|
$h = @{ Authorization = 'Basic ' + $t; 'Content-Type' = 'application/json' }
|
||||||
|
$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis'
|
||||||
|
|
||||||
|
Write-Host "Monitorando aprovacoes por 3 minutos (polling 10s)..." -ForegroundColor Cyan
|
||||||
|
|
||||||
|
for ($i = 0; $i -lt 18; $i++) {
|
||||||
|
Start-Sleep -Seconds 10
|
||||||
|
|
||||||
|
$a = Invoke-RestMethod -Uri "$base/pipelines/approvals?state=pending&api-version=7.1-preview.1" -Headers $h
|
||||||
|
$ts = Get-Date -Format 'HH:mm:ss'
|
||||||
|
|
||||||
|
if ($a.count -eq 0) {
|
||||||
|
Write-Host "$ts sem aprovacoes pendentes" -ForegroundColor Gray
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "$ts $($a.count) aprovacao(oes) pendente(s) — aprovando..." -ForegroundColor Yellow
|
||||||
|
|
||||||
|
$items = @($a.value | ForEach-Object {
|
||||||
|
@{ approvalId = $_.id; status = 'approved'; comment = 'Aprovado automaticamente via API' }
|
||||||
|
})
|
||||||
|
$body = ConvertTo-Json -InputObject $items -Depth 5
|
||||||
|
|
||||||
|
$result = Invoke-RestMethod `
|
||||||
|
-Uri "$base/pipelines/approvals?api-version=7.1-preview.1" `
|
||||||
|
-Method PATCH -Headers $h -Body $body
|
||||||
|
|
||||||
|
$result.value | ForEach-Object {
|
||||||
|
Write-Host " $($_.id) -> $($_.status)" -ForegroundColor Green
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "Monitoramento encerrado." -ForegroundColor Cyan
|
||||||
35
scripts/auto-organized/watch_approvals2.ps1
Normal file
35
scripts/auto-organized/watch_approvals2.ps1
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp'
|
||||||
|
$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p))
|
||||||
|
$h = @{ Authorization = 'Basic ' + $t; 'Content-Type' = 'application/json' }
|
||||||
|
$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis'
|
||||||
|
|
||||||
|
Write-Host "Monitorando aprovacoes por 3 minutos (polling 10s)..." -ForegroundColor Cyan
|
||||||
|
|
||||||
|
for ($i = 0; $i -lt 18; $i++) {
|
||||||
|
Start-Sleep -Seconds 10
|
||||||
|
|
||||||
|
$a = Invoke-RestMethod -Uri "$base/pipelines/approvals?state=pending&api-version=7.1-preview.1" -Headers $h
|
||||||
|
$ts = Get-Date -Format 'HH:mm:ss'
|
||||||
|
|
||||||
|
if ($a.count -eq 0) {
|
||||||
|
Write-Host "$ts sem aprovacoes pendentes" -ForegroundColor Gray
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "$ts $($a.count) aprovacao(oes) pendente(s) — aprovando..." -ForegroundColor Yellow
|
||||||
|
|
||||||
|
$items = @($a.value | ForEach-Object {
|
||||||
|
@{ approvalId = $_.id; status = 'approved'; comment = 'Aprovado automaticamente via API' }
|
||||||
|
})
|
||||||
|
$body = ConvertTo-Json -InputObject $items -Depth 5
|
||||||
|
|
||||||
|
$result = Invoke-RestMethod `
|
||||||
|
-Uri "$base/pipelines/approvals?api-version=7.1-preview.1" `
|
||||||
|
-Method PATCH -Headers $h -Body $body
|
||||||
|
|
||||||
|
$result.value | ForEach-Object {
|
||||||
|
Write-Host " $($_.id) -> $($_.status)" -ForegroundColor Green
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "Monitoramento encerrado." -ForegroundColor Cyan
|
||||||
Loading…
Reference in a new issue