mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-04-04 01:51:28 +00:00
chore: modification de la ci
This commit is contained in:
42
ci/deploy.Jenkinsfile
Normal file
42
ci/deploy.Jenkinsfile
Normal file
@ -0,0 +1,42 @@
|
||||
pipeline {
|
||||
agent { label "SLAVE-N3WT" }
|
||||
|
||||
parameters {
|
||||
choice(name: 'ENVIRONMENT', choices: ['demo', 'prod'], description: 'Choisir environnement')
|
||||
string(name: 'VERSION', defaultValue: 'v1.0.0', description: 'Version Docker à déployer')
|
||||
}
|
||||
|
||||
environment {
|
||||
PLATEFORME_DEMO = 'demo.n3wtschool.com'
|
||||
PLATEFORME_PROD = 'vps.n3wtschool.com'
|
||||
DEPLOY_DIR = '~/n3wtschool'
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Deploy') {
|
||||
steps {
|
||||
script {
|
||||
def targetHost = params.ENVIRONMENT == 'prod' ? env.PLATEFORME_PROD : env.PLATEFORME_DEMO
|
||||
def deployDir = env.DEPLOY_DIR
|
||||
|
||||
// Le credential id Jenkins qui contient la clé SSH
|
||||
def sshCredentialId = params.ENVIRONMENT == 'prod' ? 'vps_n3wt_prod' : 'demo_n3wt'
|
||||
|
||||
// Le user SSH que tu passes dans la commande ssh
|
||||
def sshUser = params.ENVIRONMENT == 'prod' ? 'root' : 'demo'
|
||||
|
||||
sshagent([sshCredentialId]) {
|
||||
sh """
|
||||
ssh -o StrictHostKeyChecking=no ${sshUser}@${targetHost} <<EOF
|
||||
cd ${deployDir}
|
||||
docker compose down
|
||||
docker compose pull
|
||||
docker compose up -d
|
||||
EOF
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user