From 8ee3824dd73275a2ddd892978f540e193dcfc806 Mon Sep 17 00:00:00 2001 From: aagusfernandez02 Date: Mon, 20 Jul 2026 09:51:28 -0300 Subject: [PATCH] feat(Jenkinsfile.sco): add new pipeline for client deployment with parameter validation --- data/jenkins/pipelines/Jenkinsfile.lab | 55 ------------------- data/jenkins/pipelines/Jenkinsfile.ralph | 56 ------------------- data/jenkins/pipelines/Jenkinsfile.sco | 70 ++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 111 deletions(-) delete mode 100644 data/jenkins/pipelines/Jenkinsfile.lab delete mode 100644 data/jenkins/pipelines/Jenkinsfile.ralph create mode 100644 data/jenkins/pipelines/Jenkinsfile.sco diff --git a/data/jenkins/pipelines/Jenkinsfile.lab b/data/jenkins/pipelines/Jenkinsfile.lab deleted file mode 100644 index 343b517..0000000 --- a/data/jenkins/pipelines/Jenkinsfile.lab +++ /dev/null @@ -1,55 +0,0 @@ -pipeline { - agent none - - parameters { - choice( - name: 'TIENDA', - choices: ['oficina'], - description: 'Tienda destino' - ) - string( - name: 'NODO', - defaultValue: '', - description: 'Nombre exacto del nodo a deployar (vacío = toda la tienda)' - ) - } - - stages { - stage('Preparar scripts') { - agent { label 'built-in' } - steps { - sh 'cp /opt/deploy/install.sh .' - stash name: 'scripts', includes: 'install.sh' - } - } - - stage('Deploy') { - agent { label 'built-in' } - steps { - script { - def labelExpr = "lab && ${params.TIENDA}" - def nodes = nodesByLabel(label: labelExpr, offline: false) - if (params.NODO?.trim()) { - def target = params.NODO.trim() - if (!nodes.contains(target)) { - error "El nodo '${target}' no está online o no pertenece al label: ${labelExpr}" - } - nodes = [target] - } - if (nodes.isEmpty()) { - error "No hay nodos online con el label: ${labelExpr}" - } - def deployStages = nodes.collectEntries { nodeName -> - ["Deploy ${nodeName}": { - node(nodeName) { - unstash 'scripts' - sh "bash install.sh 'lab'" - } - }] - } - parallel deployStages - } - } - } - } -} diff --git a/data/jenkins/pipelines/Jenkinsfile.ralph b/data/jenkins/pipelines/Jenkinsfile.ralph deleted file mode 100644 index 237ac88..0000000 --- a/data/jenkins/pipelines/Jenkinsfile.ralph +++ /dev/null @@ -1,56 +0,0 @@ -pipeline { - agent none - - parameters { - choice( - name: 'TIENDA', - choices: ['yabucoa', 'san-lorenzo', 'rio-grande'], - description: 'Tienda destino' - ) - string( - name: 'NODO', - defaultValue: '', - description: 'Nombre exacto del nodo a deployar (vacío = toda la tienda)' - ) - } - - stages { - stage('Preparar scripts') { - agent { label 'built-in' } - steps { - sh 'cp /opt/deploy/install.sh .' - stash name: 'scripts', includes: 'install.sh' - } - } - - stage('Deploy') { - agent { label 'built-in' } - steps { - script { - def labelExpr = "ralph && ${params.TIENDA}" - def nodes = nodesByLabel(label: labelExpr, offline: false) - if (params.NODO?.trim()) { - def target = params.NODO.trim() - if (!nodes.contains(target)) { - error "El nodo '${target}' no está online o no pertenece al label: ${labelExpr}" - } - nodes = [target] - } - if (nodes.isEmpty()) { - error "No hay nodos online con el label: ${labelExpr}" - } - def deployStages = nodes.collectEntries { nodeName -> - ["Deploy ${nodeName}": { - node(nodeName) { - unstash 'scripts' - sh "bash install.sh 'mbs-ralphs'" - sh 'cat ~/sco-app/installed.txt' - } - }] - } - parallel deployStages - } - } - } - } -} diff --git a/data/jenkins/pipelines/Jenkinsfile.sco b/data/jenkins/pipelines/Jenkinsfile.sco new file mode 100644 index 0000000..8d93cab --- /dev/null +++ b/data/jenkins/pipelines/Jenkinsfile.sco @@ -0,0 +1,70 @@ + pipeline { + agent none + parameters { + string( + name: 'NODO', + defaultValue: '', + description: 'Nombre exacto del nodo a deployar' + ) + choice( + name: 'CLIENTE', + choices: [ + 'SELECCIONAR_CLIENTE', + 'cencosud-jumbo', + 'censosud-staisabel', + 'changomas-hiper', + 'changomas-super', + 'dibal', + 'hisense', + 'lsco', + 'mbs-econo', + 'mbs-famcoop', + 'mbs-ralphs', + 'mbs-supermax', + 'modatelas', + 'walmart-chile-acuenta', + 'walmart-chile-lider', + 'wm-mexico-bodega', + 'wm-mexico-walmart' + ], + description: 'Cliente para el cual se ejecuta el deploy' + ) + } + stages { + stage('Registro de parámetros') { + agent none + when { expression { params.CLIENTE == null } } + steps { + echo 'Primer build: Jenkins está registrando los parámetros de este Jenkinsfile. No se ejecuta ningún deploy. Volvé a correr el job con "Build with Parameters".' + script { currentBuild.result = 'NOT_BUILT' } + } + } + stage('Preparar scripts') { + agent { label 'built-in' } + when { expression { params.CLIENTE != null } } + steps { + sh 'cp /opt/deploy/install.sh .' + stash name: 'scripts', includes: 'install.sh' + } + } + stage('Deploy') { + agent { label 'built-in' } + when { expression { params.CLIENTE != null } } + steps { + script { + if (!params.NODO?.trim()) { + error "El parámetro NODO es obligatorio" + } + if (params.CLIENTE == 'SELECCIONAR_CLIENTE') { + error "El parámetro CLIENTE es obligatorio" + } + def target = params.NODO.trim() + node(target) { + unstash 'scripts' + sh "bash install.sh '${params.CLIENTE.trim()}'" + } + } + } + } + } +} \ No newline at end of file