pipeline { agent none parameters { string(name: 'NODO', defaultValue: '', description: 'Nombre exacto del agente SCO (ej: ralph-yabucoa-sco05)') } stages { stage('Registro de parámetros') { agent none when { expression { params.NODO == null } } steps { echo 'Primer build: Jenkins está registrando los parámetros de este Jenkinsfile. No se ejecuta nada. Volvé a correr el job con "Build with Parameters".' script { currentBuild.result = 'NOT_BUILT' } } } stage('Preparar scripts') { agent { label 'built-in' } when { expression { params.NODO != null } } steps { sh 'cp /opt/history/history.sh .' stash name: 'scripts', includes: 'history.sh' } } stage('Reprocesar historial') { agent { label 'built-in' } when { expression { params.NODO != null } } steps { script { if (!params.NODO?.trim()) { error "El parámetro NODO es obligatorio" } def target = params.NODO.trim() node(target) { unstash 'scripts' timeout(time: 30, unit: 'MINUTES') { sh 'bash history.sh' } } } } } } }