|
|
@@ -1,110 +1,37 @@
|
|
|
-node{
|
|
|
- stage('Prepare Node and NPM') { // confirm nodejs plugin and setting
|
|
|
- env.NODEJS_HOME = "${tool 'NodeJS'}"
|
|
|
- //on linux / mac
|
|
|
+node{
|
|
|
+
|
|
|
+ env.NODEJS_HOME = "${tool 'NodeJS'}"
|
|
|
+ // on linux / mac
|
|
|
env.PATH="${env.NODEJS_HOME}/bin:${env.PATH}"
|
|
|
// on windows
|
|
|
- //env.PATH="${env.NODEJS_HOME};${env.PATH}"
|
|
|
- sh'node --version'
|
|
|
+ //env.PATH="${env.NODEJS_HOME};${env.PATH}"
|
|
|
sh 'npm --version'
|
|
|
-
|
|
|
- }
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- stage('checkout'){
|
|
|
- deleteDir()
|
|
|
- checkout scm
|
|
|
- echo 'Pulling..................' + env.BRANCH_NAME
|
|
|
- }
|
|
|
- stage('Stop Container'){
|
|
|
- sh 'docker ps | grep "workflow_" -v | awk -F " " \'{if(NR>1)print $1}\' | xargs docker kill | xargs docker rm || true'
|
|
|
- sh 'docker system prune -f'
|
|
|
- }
|
|
|
- //stage('Build Container')
|
|
|
- // {
|
|
|
- // imageApache=docker.build('server-apache-dev', '--no-cache -f build/docker/apache/Dockerfile .')
|
|
|
- // imageSql=docker.build('server-mysql-dev', '--no-cache -f build/docker/mysql/Dockerfile .')
|
|
|
- // containerMysql=imageSql.run('--name server-mysql-dev')
|
|
|
- // containerApache=imageApache.run('-p 8080:80 --link server-mysql-dev:mysql')
|
|
|
- // }
|
|
|
- // stage('Waiting Container'){
|
|
|
- // waitUntil{
|
|
|
- // try{
|
|
|
- // sh "docker exec ${containerApache.id} php -v"
|
|
|
- // return true
|
|
|
- // } catch(Exception $e){
|
|
|
- // return false
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
- stage('stage 1bis'){
|
|
|
- sh 'docker -v'
|
|
|
- sh 'docker ps'
|
|
|
- }
|
|
|
-
|
|
|
- stage('stage 2bis'){
|
|
|
- sh 'ls -ls'
|
|
|
- }
|
|
|
-// stage('Test') {
|
|
|
-
|
|
|
-// dir("${env.WORKSPACE}/angular-client") {
|
|
|
-// sh 'npm i @angular-devkit/build-angular@0.901.15 typescript@3.8.3 @angular/compiler-cli@9.1.4'
|
|
|
-
|
|
|
-// try {
|
|
|
-
|
|
|
-// // Exporter la variable d'environnement NODE_OPTIONS
|
|
|
-// sh 'npm run test-ci'
|
|
|
-
|
|
|
-// } catch(err) {
|
|
|
-// sh 'echo TEST FAILED'
|
|
|
-// junit 'target/surefire-reports/TESTS-TestSuite.xml/*.xml'
|
|
|
-// throw err
|
|
|
-// }
|
|
|
-// }
|
|
|
-
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
- // def imageApache = stage("Build apache preprod")
|
|
|
- // {
|
|
|
- // docker.build("server-apache-preprod", "--no-cache --label traefik.enable=true --label traefik.http.routers.server-apache-preprod.rule='Host(`angular-preprod.foodgame.fr`)' --label traefik.http.routers.server-apache-preprod.entrypoints=websecure --label traefik.http.routers.server-apache-preprod.tls.certresolver=myresolver -f build/docker/httpd/Dockerfile .")
|
|
|
- // }
|
|
|
-
|
|
|
- // def imageExpress = stage("Build express preprod")
|
|
|
- // {
|
|
|
- // docker.build("server-express-preprod", "--no-cache -f express-server/Dockerfile express-server")
|
|
|
- // }
|
|
|
-
|
|
|
- /*stage("Run Container express preprod")
|
|
|
- {
|
|
|
- containerSql=imageExpress.run("--name server-express-preprod -v /var/log:/var/www/app/log/root --link database_preprod:mongo --network=web")
|
|
|
- }
|
|
|
- stage("Run Container apache preprod")
|
|
|
- {
|
|
|
- containerApache=imageApache.run("--name server-apache-preprod --link server-mysql-preprod:mysql --network=web")
|
|
|
- }*/
|
|
|
-
|
|
|
-
|
|
|
- /*stage("Run Container express preprod")
|
|
|
+ stage('checkout')
|
|
|
{
|
|
|
- containerSql=imageExpress.run("--name server-express-preprod -v /home/projet/fatboar/${e}/mysql:/var/lib/mysql --network=web")
|
|
|
+ deleteDir()
|
|
|
+ checkout scm
|
|
|
}
|
|
|
+
|
|
|
+ stage('Stop Containers')
|
|
|
+ {
|
|
|
+ sh 'docker ps | grep "workflow_" -v | awk -F " " \'{ if(NR>1) print $1}\' |xargs docker kill |xargs docker rm || true'
|
|
|
+ sh 'docker system prune -f'
|
|
|
+ }
|
|
|
|
|
|
- stage("Run Container apache preprod")
|
|
|
- {
|
|
|
- containerApache=imageApache.run("--name server-apache-preprod --link server-mysql-preprod:mysql --network=web")
|
|
|
- }*/
|
|
|
-
|
|
|
-
|
|
|
- // stage("Push preprod images to nexus")
|
|
|
+
|
|
|
+ // stage("Push preprod images to nexus")
|
|
|
// {
|
|
|
- // /*docker.withRegistry('http://localhost:8083','885ef60c-9352-489a-bd1c-e4b695747c21')
|
|
|
+ // docker.withRegistry('http://localhost:8083','885ef60c-9352-489a-bd1c-e4b695747c21')
|
|
|
// {
|
|
|
- // imageApache.push('latest')
|
|
|
- // imageExpress.push('latest')
|
|
|
- // }*/
|
|
|
+ // imageApache.push('latest')
|
|
|
+ // imageExpress.push('latest')
|
|
|
+ // }
|
|
|
// }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
stage('SonarQube analysis')
|
|
|
{
|
|
|
def scannerHome = tool name: 'SonarQube Scanner', type: 'hudson.plugins.sonar.SonarRunnerInstallation';
|
|
|
@@ -120,9 +47,10 @@ node{
|
|
|
}
|
|
|
|
|
|
|
|
|
- stage('Build Docker MEAN Stack(Test Deployment)')
|
|
|
+ stage('Build Docker MEAN Stack(PreProduction Deployment)')
|
|
|
{
|
|
|
sh 'docker-compose -v'
|
|
|
+ sh 'docker-compose stop'
|
|
|
sh 'docker-compose build'
|
|
|
sh 'docker-compose up -d'
|
|
|
}
|