Test: Pipeline proyectosacc para laboratorio local

This commit is contained in:
Test
2026-06-03 03:55:02 +00:00
parent 68ab139d77
commit 61549be0f1
4 changed files with 254 additions and 43 deletions
Vendored
+132 -43
View File
@@ -1,65 +1,154 @@
pipeline {
agent {
docker {
image 'amazon/aws-cli:latest'
args '-u root --entrypoint="" --network ci-network -v /var/run/docker.sock:/var/run/docker.sock'
}
}
agent any
environment {
AWS_ACCESS_KEY_ID = "000000000000"
AWS_ACCESS_KEY_ID = "000000000000"
AWS_SECRET_ACCESS_KEY = "test"
AWS_DEFAULT_REGION = "us-east-1"
AWS_ENDPOINT = "http://floci:4566"
APP_NAME = "demo-app"
REGISTRY = "172.16.20.100:5000"
AWS_DEFAULT_REGION = "us-east-1"
AWS_ENDPOINT_URL = "http://floci:4566"
ENV = "local"
}
stages {
stage('Analisis de Calidad') {
stage('01_image-setup') {
steps {
echo "Simulando analisis con SonarQube..."
withSonarQubeEnv('SonarLocal') {
echo "Enviando metricas a SonarQube (simulado)"
}
}
}
stage('Construccion y Empaquetado') {
steps {
echo "Construyendo imagen Docker..."
echo "=== Setup del entorno local ==="
sh '''
cat > Dockerfile <<'DOCKER'
FROM nginx:alpine
RUN echo "Hola desde Floci" > /usr/share/nginx/html/index.html
DOCKER
echo "✓ Docker disponible: $(docker --version)"
echo "✓ AWS CLI disponible: $(aws --version)"
'''
sh "docker build -t \${REGISTRY}/\${APP_NAME}:latest ."
}
}
stage('Publicar en Registry Local') {
stage('02_local-aws-setup') {
steps {
echo "Subiendo artefacto..."
sh "docker push \${REGISTRY}/\${APP_NAME}:latest"
echo "Imagen publicada."
echo "=== Configurando AWS Local (Floci) ==="
sh '''
bash scripts/aws-local-setup.sh local
'''
}
}
stage('Despliegue en Infraestructura (Floci AWS)') {
stage('03_test-s3-operations') {
steps {
echo "Desplegando en AWS emulado..."
sh 'aws --endpoint-url=\${AWS_ENDPOINT} s3 mb s3://\${APP_NAME}-bucket || true'
sh 'echo "Configuracion de produccion" > config.json'
sh 'aws --endpoint-url=\${AWS_ENDPOINT} s3 cp config.json s3://\${APP_NAME}-bucket/'
sh 'aws --endpoint-url=\${AWS_ENDPOINT} s3 ls s3://\${APP_NAME}-bucket/'
echo "=== Probando operaciones S3 en Floci ==="
sh '''
export AWS_ACCESS_KEY_ID="000000000000"
export AWS_SECRET_ACCESS_KEY="test"
export AWS_DEFAULT_REGION="us-east-1"
echo "Creando bucket de prueba..."
aws --endpoint-url=http://floci:4566 s3 mb s3://proyectosacc-test-bucket || true
echo "Listando buckets..."
aws --endpoint-url=http://floci:4566 s3 ls
echo "Subiendo archivo de prueba..."
echo "test content" > /tmp/test-file.txt
aws --endpoint-url=http://floci:4566 s3 cp /tmp/test-file.txt s3://proyectosacc-test-bucket/
echo "Verificando contenido..."
aws --endpoint-url=http://floci:4566 s3 ls s3://proyectosacc-test-bucket/
echo "✓ Operaciones S3 completadas"
'''
}
}
stage('04_simular-build') {
steps {
echo "=== Simulando build de aplicación ==="
sh '''
echo "✓ Compilando frontend (simulado)"
echo "✓ Compilando backend JARs (simulado)"
mkdir -p build/libs
echo "simulated-jar" > build/libs/app.jar
echo "✓ Artefactos generados"
'''
}
}
stage('05_publish-local') {
steps {
echo "=== Publicando artefactos localmente ==="
sh '''
export AWS_ACCESS_KEY_ID="000000000000"
export AWS_SECRET_ACCESS_KEY="test"
export AWS_DEFAULT_REGION="us-east-1"
echo "Subiendo a S3 local..."
aws --endpoint-url=http://floci:4566 s3 cp build/libs/app.jar s3://proyectosacc-test-bucket/artifacts/ || true
echo "Subiendo frontend a S3..."
echo "frontend-content" > /tmp/frontend.zip
aws --endpoint-url=http://floci:4566 s3 cp /tmp/frontend.zip s3://proyectosacc-test-bucket/frontend/ || true
echo "✓ Publish completado"
'''
}
}
stage('06_deploy-local') {
steps {
echo "=== Ejecutando deploy local ==="
sh '''
bash scripts/deploy-local.sh local
'''
}
}
stage('07_health-check') {
steps {
echo "=== Health Check ==="
sh '''
echo "Verificando servicios locales..."
# Verificar Jenkins
if curl -sf http://jenkins:8080/login > /dev/null; then
echo "✓ Jenkins - OK"
fi
# Verificar Gitea
if curl -sf http://gitea:3000 > /dev/null; then
echo "✓ Gitea - OK"
fi
# Verificar SonarQube
if curl -sf http://sonarqube:9000 > /dev/null; then
echo "✓ SonarQube - OK"
fi
# Verificar Registry
if curl -sf http://registry:5000/v2/ > /dev/null; then
echo "✓ Registry - OK"
fi
# Verificar Floci
if curl -sf http://floci:4566 > /dev/null; then
echo "✓ Floci (AWS) - OK"
fi
echo "✓ Todos los servicios del laboratorio están activos"
'''
}
}
}
post {
always {
echo "Pipeline finalizado."
echo "=== Pipeline de prueba completado ==="
echo "El pipeline ha demostrado:"
echo " 1. Configuración de credenciales AWS (Floci)"
echo " 2. Operaciones S3 (create bucket, upload, list)"
echo " 3. Simulación de build y publish"
echo " 4. Deploy local simulado"
echo " 5. Health check de todos los servicios"
}
success {
echo "✅ PIPELINE EXITOSO"
}
failure {
echo "❌ PIPELINE FALLÓ"
}
}
}