add Docker configuration and Jenkins pipeline for application deployment
This commit is contained in:
85
jenkinsfile
Normal file
85
jenkinsfile
Normal file
@@ -0,0 +1,85 @@
|
||||
pipeline {
|
||||
agent any
|
||||
|
||||
tools {
|
||||
maven 'mvn'
|
||||
nodejs 'npm'
|
||||
}
|
||||
|
||||
environment {
|
||||
JAVA_HOME = '/opt/java/openjdk'
|
||||
PATH = "${JAVA_HOME}/bin:${env.PATH}"
|
||||
SPRING_IMAGE_NAME = 'spring-jenkins'
|
||||
ANGULAR_IMAGE_NAME = 'angular-jenkins'
|
||||
IMAGE_TAG = 'latest'
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Checkout sur la branche dev') {
|
||||
steps {
|
||||
git branch: 'dev', url: 'https://gitea.unifihomenetwork.com/vincentguillet/gameovergne-app.git'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Maven Build') {
|
||||
steps {
|
||||
dir('api') {
|
||||
sh 'mvn compile'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Angular Build') {
|
||||
steps {
|
||||
dir('client') {
|
||||
sh 'npm install'
|
||||
sh 'npm run build'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Maven Test') {
|
||||
steps {
|
||||
dir('api') {
|
||||
sh 'mvn test'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Spring Docker Build') {
|
||||
steps {
|
||||
dir('api') {
|
||||
sh 'docker-compose build spring'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Angular Docker Build') {
|
||||
steps {
|
||||
dir('client') {
|
||||
sh 'docker-compose build angular'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Spring Deployment') {
|
||||
steps {
|
||||
sh """
|
||||
docker-compose stop spring
|
||||
docker-compose rm spring
|
||||
docker-compose up -d --no-recreate spring
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
stage('Angular Deployment') {
|
||||
steps {
|
||||
sh """
|
||||
docker-compose stop angular
|
||||
docker-compose rm angular
|
||||
docker-compose up -d --no-recreate angular
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user