50 lines
1.1 KiB
Groovy
50 lines
1.1 KiB
Groovy
pipeline {
|
|
agent any
|
|
|
|
environment {
|
|
APP_NAME = 'no-whatever'
|
|
}
|
|
|
|
triggers {
|
|
gitlab(triggerOnPush: true, branchFilterType: 'All')
|
|
}
|
|
|
|
stages {
|
|
stage('Checkout') {
|
|
steps {
|
|
checkout scm
|
|
}
|
|
}
|
|
|
|
stage('Build Docker Image') {
|
|
steps {
|
|
sh "docker build -t ${APP_NAME}:${BUILD_NUMBER} -t ${APP_NAME}:latest ."
|
|
}
|
|
}
|
|
|
|
stage('Deploy') {
|
|
steps {
|
|
sh """
|
|
docker stop ${APP_NAME} || true
|
|
docker rm ${APP_NAME} || true
|
|
docker run -d \
|
|
--name ${APP_NAME} \
|
|
-p 3000:3000 \
|
|
-v ${APP_NAME}-data:/app/data \
|
|
--restart unless-stopped \
|
|
${APP_NAME}:latest
|
|
"""
|
|
}
|
|
}
|
|
}
|
|
|
|
post {
|
|
success {
|
|
echo "Deployed ${APP_NAME} build #${BUILD_NUMBER} successfully"
|
|
}
|
|
failure {
|
|
echo "Build #${BUILD_NUMBER} failed"
|
|
}
|
|
}
|
|
}
|