workspace-v1/control-plane/ci/jenkins/Jenkinsfile.template
Adrian Flores Cortes 967ab360bb Initial commit: Workspace v1 with 3-layer architecture
Structure:
- control-plane/: Registries, SIMCO directives, CI/CD templates
- projects/: Gamilit, ERP-Suite, Trading-Platform, Betting-Analytics
- shared/: Libs catalog, knowledge-base

Key features:
- Centralized port, domain, database, and service registries
- 23 SIMCO directives + 6 fundamental principles
- NEXUS agent profiles with delegation rules
- Validation scripts for workspace integrity
- Dockerfiles for all services
- Path aliases for quick reference

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 00:35:19 -06:00

155 lines
4.9 KiB
Plaintext

// ==============================================================================
// JENKINSFILE TEMPLATE - Control Plane
// ==============================================================================
// Proposito: Template base para pipelines de CI/CD
// Uso: Copiar y adaptar para cada servicio
// ==============================================================================
pipeline {
agent any
environment {
// Variables del servicio (personalizar)
SERVICE_NAME = '{{SERVICE_NAME}}'
PROJECT_NAME = '{{PROJECT_NAME}}'
// Paths del Control Plane
CONTROL_PLANE = "${env.WORKSPACE_ROOT}/control-plane"
REGISTRIES = "${CONTROL_PLANE}/registries"
VALIDATION_SCRIPTS = "${CONTROL_PLANE}/devtools/scripts/validation"
// Docker
DOCKER_REGISTRY = 'ghcr.io/{{ORG_NAME}}'
DOCKER_IMAGE = "${DOCKER_REGISTRY}/${PROJECT_NAME}-${SERVICE_NAME}"
}
options {
timeout(time: 30, unit: 'MINUTES')
disableConcurrentBuilds()
buildDiscarder(logRotator(numToKeepStr: '10'))
}
stages {
// ======================================================================
// FASE 1: VALIDACION PRE-BUILD
// ======================================================================
stage('Validate') {
steps {
echo "=== Validando contra registries ==="
// Validar puertos
sh """
${VALIDATION_SCRIPTS}/validate-ports.sh || exit 1
"""
// Validar service descriptor
sh """
${VALIDATION_SCRIPTS}/validate-service-descriptors.sh || exit 1
"""
// Validar dominios
sh """
${VALIDATION_SCRIPTS}/validate-domains.sh || exit 1
"""
}
}
// ======================================================================
// FASE 2: BUILD
// ======================================================================
stage('Build') {
steps {
echo "=== Building ${SERVICE_NAME} ==="
dir("${PROJECT_PATH}") {
// Node.js projects
sh """
npm ci
npm run build
npm run lint
"""
}
}
}
// ======================================================================
// FASE 3: TEST
// ======================================================================
stage('Test') {
steps {
echo "=== Running tests ==="
dir("${PROJECT_PATH}") {
sh """
npm run test:ci || true
"""
}
}
post {
always {
// Publicar resultados de tests
junit allowEmptyResults: true, testResults: '**/junit.xml'
}
}
}
// ======================================================================
// FASE 4: DOCKER BUILD
// ======================================================================
stage('Docker Build') {
when {
anyOf {
branch 'main'
branch 'develop'
tag pattern: "v\\d+\\.\\d+\\.\\d+.*", comparator: "REGEXP"
}
}
steps {
echo "=== Building Docker image ==="
dir("${PROJECT_PATH}") {
sh """
docker build -t ${DOCKER_IMAGE}:${GIT_COMMIT_SHORT} .
docker tag ${DOCKER_IMAGE}:${GIT_COMMIT_SHORT} ${DOCKER_IMAGE}:latest
"""
}
}
}
// ======================================================================
// FASE 5: DEPLOY (solo en tags)
// ======================================================================
stage('Deploy') {
when {
tag pattern: "v\\d+\\.\\d+\\.\\d+.*", comparator: "REGEXP"
}
steps {
echo "=== Deploying ${SERVICE_NAME} ==="
sh """
docker push ${DOCKER_IMAGE}:${GIT_COMMIT_SHORT}
docker push ${DOCKER_IMAGE}:latest
"""
// Trigger deploy script
sh """
echo "Deploy triggered for ${SERVICE_NAME}"
"""
}
}
}
post {
success {
echo "Pipeline completed successfully"
}
failure {
echo "Pipeline failed"
// Notificar en caso de fallo
}
always {
cleanWs()
}
}
}