feat: jenkins server
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
pipeline {
|
||||
agent none
|
||||
|
||||
parameters {
|
||||
choice(
|
||||
name: 'TIENDA',
|
||||
choices: ['yabucoa', 'san-lorenzo', 'rio-grande'],
|
||||
description: 'Tienda destino'
|
||||
)
|
||||
}
|
||||
|
||||
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 (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 'ralph'"
|
||||
sh 'cat ~/sco-app/installed.txt'
|
||||
}
|
||||
}]
|
||||
}
|
||||
parallel deployStages
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user