Files
Geradores/Jenkinsfile
Marco Santos d7ea8a9b9e Reescrita dos geradores: biblioteca IGenerator, minimal API e novo frontend
- GeradoresService: cada tipo passa a ser um IGenerator (NIF, NIPC, NISS, CC,
  passaporte, IBAN, NIB, cartões, referência MB, pessoa, telefone, código postal,
  email, matrícula, EAN, UUID) registado em GeneratorRegistry; remove DAL/EF
- GeradoresWS: minimal APIs em /api/v1 com OpenAPI + Scalar e health check
- UnitTest: testes de ida e volta, valores conhecidos, detecção e API
- geradoresfe: UI construída a partir dos metadados da API, validador livre,
  exportação CSV/JSON/TXT, nginx com API_UPSTREAM configurável
- Docker, docker-compose e Jenkinsfile actualizados

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 23:51:39 +01:00

100 lines
2.8 KiB
Groovy

pipeline {
agent any
environment {
DOCKER_REGISTRY = 'git.homeware.pt/marco'
DOCKER_TAG = "${env.BUILD_ID}"
REACT_DIR = 'geradoresfe'
REACT_IMAGE = "${DOCKER_REGISTRY}/geradores/fe:${DOCKER_TAG}"
WS_IMAGE = "${DOCKER_REGISTRY}/geradores/ws:${DOCKER_TAG}"
DOCKER_CREDENTIALS_ID = 'docker-registry-creds'
KUBECONFIG_CREDENTIALS_ID = 'kubeconfig-jenkins'
GIT_CREDENTIALS_ID = '3e806a5c-ee46-49fb-974d-15f3fe2e1d49'
}
stages {
stage('Preparar Ambiente') {
steps {
script {
echo "Verificar Docker local"
sh 'docker version'
}
}
}
stage('Checkout Repositório') {
steps {
git branch: 'master',
url: 'https://git.homeware.pt/Marco/Geradores.git',
credentialsId: env.GIT_CREDENTIALS_ID
}
}
stage('Testes .NET') {
steps {
// Compila Service + WS e corre os testes (requer .NET 10 SDK no agente).
sh 'dotnet test UnitTest/UnitTest.csproj -c Release'
}
}
stage('Testes e Build React') {
steps {
dir("${REACT_DIR}") {
sh 'npm ci'
sh 'npm run lint'
sh 'npm test'
sh 'npm run build'
}
}
}
stage('Docker Build Imagens') {
steps {
script {
docker.build("${WS_IMAGE}")
docker.build("${REACT_IMAGE}", "${REACT_DIR}")
}
}
}
stage('Push para Docker Registry') {
steps {
script {
docker.withRegistry("https://${DOCKER_REGISTRY}", GIT_CREDENTIALS_ID) {
docker.image("${WS_IMAGE}").push()
docker.image("${REACT_IMAGE}").push()
}
}
}
}
stage('Deploy no Kubernetes') {
steps {
withKubeConfig(credentialsId: KUBECONFIG_CREDENTIALS_ID) {
script {
// Substitui as imagens no manifest e aplica
sh """
sed 's|{{WS_IMAGE}}|${WS_IMAGE}|g; s|{{FE_IMAGE}}|${REACT_IMAGE}|g' k8s/deployment.template.yaml > k8s/deployment.yaml
kubectl apply -f k8s/deployment.yaml
"""
}
}
}
}
}
post {
success {
echo 'Deploy feito com sucesso!'
sh 'docker system prune -f'
}
failure {
echo 'Erro no pipeline. Verifica os logs!'
}
}
}