|
@@ -1,60 +1,227 @@
|
|
|
-node{
|
|
|
|
|
- stage('checkout'){
|
|
|
|
|
|
|
+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 'npm --version'
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ stage('checkout')
|
|
|
|
|
+ {
|
|
|
deleteDir()
|
|
deleteDir()
|
|
|
checkout scm
|
|
checkout scm
|
|
|
}
|
|
}
|
|
|
- stage('Stop Container'){
|
|
|
|
|
- //sh 'docker ps | grep "workflow_" -v | awk -F " " \'{if(NR>1)print $1}\' | xargs docker killdo | xargs docker rm || true'
|
|
|
|
|
- //sh 'docker system prune -f'
|
|
|
|
|
|
|
|
|
|
|
|
+ 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 ps | grep "workflow_" -v | awk -F " " \'{ if(NR>1) print $1}\' |xargs docker kill |xargs docker rm || true'
|
|
|
- sh 'docker system prune -f'
|
|
|
|
|
|
|
+ sh 'docker system prune -f'
|
|
|
}
|
|
}
|
|
|
- /*stage('Build Container')
|
|
|
|
|
|
|
+
|
|
|
|
|
+ stage('SonarQube analysis')
|
|
|
{
|
|
{
|
|
|
- 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')
|
|
|
|
|
- }*/
|
|
|
|
|
|
|
+ def scannerHome = tool 'SonarQube Scanner 2.8';
|
|
|
|
|
+ withSonarQubeEnv('SonarQube')
|
|
|
|
|
+ {
|
|
|
|
|
+ // If you have configured more than one global server connection, you can specify its name
|
|
|
|
|
+ sh "${scannerHome}/bin/sonar-scanner -Dsonar.login=admin -Dsonar.password=SonarQubeCodeFuriousDucks2020"
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ stage('Test')
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ dir("${env.WORKSPACE}/angular-client")
|
|
|
|
|
+ {
|
|
|
|
|
+ sh 'npm i @angular-devkit/build-angular'
|
|
|
|
|
+
|
|
|
|
|
+ try
|
|
|
|
|
+ {
|
|
|
|
|
+ sh 'npm run test-ci'
|
|
|
|
|
+ }
|
|
|
|
|
+ catch(err)
|
|
|
|
|
+ {
|
|
|
|
|
+ sh 'echo TEST FAILED'
|
|
|
|
|
+ junit 'target/surefire-reports/TESTS-TestSuite.xml/*.xml'
|
|
|
|
|
+ throw err
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /*def karma = docker.image('trion/ng-cli-karma')
|
|
|
|
|
+ karma.pull()
|
|
|
|
|
+
|
|
|
|
|
+ try
|
|
|
|
|
+ {
|
|
|
|
|
+ karma.run(' -u $(id -u) -v ${WORKSPACE}:/app trion/ng-cli-karma ')
|
|
|
|
|
+ karma.inside
|
|
|
|
|
+ {
|
|
|
|
|
+ sh 'npm install'
|
|
|
|
|
+
|
|
|
|
|
+ try
|
|
|
|
|
+ {
|
|
|
|
|
+ sh ('./node_modules/karma/bin/karma start karma.conf.js')
|
|
|
|
|
+ }
|
|
|
|
|
+ catch(err)
|
|
|
|
|
+ {
|
|
|
|
|
+ sh 'echo TEST FAILED'
|
|
|
|
|
+ step([$class: 'JUnitResultArchiver', testResults: 'target/surefire-reports/TESTS-TestSuite.xml/*.xml', healthScaleFactor: 1.0])
|
|
|
|
|
+ throw err
|
|
|
|
|
+ }
|
|
|
|
|
+ sh 'echo DO SOMETHING ELSE AFTER TEST'
|
|
|
|
|
+ }
|
|
|
|
|
+ sh 'ls -al '
|
|
|
|
|
+ }
|
|
|
|
|
+ catch(err)
|
|
|
|
|
+ {
|
|
|
|
|
+ sh 'echo RUN DOCKER FAILED'
|
|
|
|
|
+ throw err
|
|
|
|
|
+ }*/
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ stage('Build Angular PreProduction')
|
|
|
|
|
+ {
|
|
|
|
|
+ //sh 'docker build -f build/docker/apache/Dockerfile -t sample-app:0.1 angular-client/dist'
|
|
|
|
|
+ //sh 'docker run -d -p 8080:80 --name sample-app sample-app:0.1'
|
|
|
|
|
+
|
|
|
|
|
+ //imageApache=docker.build('server-apache-dev', '--no-cache -f build/docker/apache/Dockerfile .')
|
|
|
|
|
+ //containerApache=imageApache.run('-p 8080:80')
|
|
|
|
|
+
|
|
|
|
|
+ dir("${env.WORKSPACE}/angular-client")
|
|
|
|
|
+ {
|
|
|
|
|
+ //sh 'npm install'
|
|
|
|
|
+ //sh 'npm run-script build'
|
|
|
|
|
+ //sh 'npm install -g firebase-tools'
|
|
|
|
|
+ //sh 'firebase deploy --token 1//034mfWw9ZUdOKCgYIARAAGAMSNwF-L9Ir-Ql0JG0M9RA3PJStufMSA-2gEVAiyiu6_plL9KQdHn3kuIiNGBVuDQpotPgjltv4nWc'
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
def imageApache = stage("Build apache preprod")
|
|
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 .")
|
|
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 .")
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- stage("Run Container apache preprod")
|
|
|
|
|
|
|
+
|
|
|
|
|
+ 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 /home/projet/fatboar/${e}/mysql:/var/lib/mysql --network=web")
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ stage("Run Container apache preprod")
|
|
|
{
|
|
{
|
|
|
containerApache=imageApache.run("--name server-apache-preprod --link server-mysql-preprod:mysql --network=web")
|
|
containerApache=imageApache.run("--name server-apache-preprod --link server-mysql-preprod:mysql --network=web")
|
|
|
|
|
+ }*/
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ stage("Push preprod images to nexus")
|
|
|
|
|
+ {
|
|
|
|
|
+ /*docker.withRegistry('http://localhost:8083','885ef60c-9352-489a-bd1c-e4b695747c21')
|
|
|
|
|
+ {
|
|
|
|
|
+ imageApache.push('latest')
|
|
|
|
|
+ imageExpress.push('latest')
|
|
|
|
|
+ }*/
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
|
|
|
- /*stage('Waiting Container'){
|
|
|
|
|
- waitUntil{
|
|
|
|
|
- try{
|
|
|
|
|
|
|
+ stage('Build Docker MEAN Stack(PreProduction Deployment)')
|
|
|
|
|
+ {
|
|
|
|
|
+ sh 'docker-compose -v'
|
|
|
|
|
+ sh 'docker-compose build'
|
|
|
|
|
+ sh 'docker-compose up -d'
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ stage('Fin du Pipeline')
|
|
|
|
|
+ {
|
|
|
|
|
+ sh 'echo "Félicitation tout c\'est bien déroulé!"'
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /*stage('Waiting Container') {
|
|
|
|
|
+ waitUntil {
|
|
|
|
|
+ try {
|
|
|
sh "docker exec ${containerApache.id} php -v"
|
|
sh "docker exec ${containerApache.id} php -v"
|
|
|
- return true
|
|
|
|
|
- } catch(Exception $e){
|
|
|
|
|
- return false
|
|
|
|
|
|
|
+ return true
|
|
|
|
|
+ } catch (Exception $e) {
|
|
|
|
|
+ return false
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
- }*/
|
|
|
|
|
- stage('stage 1bis'){
|
|
|
|
|
- sh 'docker -v'
|
|
|
|
|
- sh 'docker ps'
|
|
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
|
|
+ waitUntil {
|
|
|
|
|
+ try {
|
|
|
|
|
+ sh "docker exec ${containerMySQL.id} mysql --version"
|
|
|
|
|
+ return true
|
|
|
|
|
+ } catch(Exception $e) {
|
|
|
|
|
+ return false
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }*/
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+// node{
|
|
|
|
|
+// stage('checkout'){
|
|
|
|
|
+// deleteDir()
|
|
|
|
|
+// checkout scm
|
|
|
|
|
+// }
|
|
|
|
|
+// stage('Stop Container'){
|
|
|
|
|
+// //sh 'docker ps | grep "workflow_" -v | awk -F " " \'{if(NR>1)print $1}\' | xargs docker killdo | xargs docker rm || true'
|
|
|
|
|
+// //sh 'docker system prune -f'
|
|
|
|
|
+
|
|
|
|
|
+// 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')
|
|
|
|
|
+// }*/
|
|
|
|
|
+
|
|
|
|
|
+// 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 .")
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+// stage("Run Container apache preprod")
|
|
|
|
|
+// {
|
|
|
|
|
+// containerApache=imageApache.run("--name server-apache-preprod --link server-mysql-preprod:mysql --network=web")
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+// /*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('stage 2bis'){
|
|
|
|
|
+// sh 'ls -ls'
|
|
|
|
|
+// }
|
|
|
|
|
|
|
|
- stage('SonarQube analysis') {
|
|
|
|
|
- def scannerHome = tool 'sonar_scanner';
|
|
|
|
|
|
|
+// stage('SonarQube analysis') {
|
|
|
|
|
+// def scannerHome = tool 'sonar_scanner';
|
|
|
|
|
|
|
|
- withSonarQubeEnv('FatboarSonar')
|
|
|
|
|
- {
|
|
|
|
|
- // If you have configured more than one global server connection, you can specify its name
|
|
|
|
|
- //sh "${scannerHome}/bin/sonar-scanner -Dsonar.login=admin -Dsonar.password=admin" }
|
|
|
|
|
- sh "${scannerHome}/bin/sonar-scanner -Dsonar.projectKey=Fatboar_project -Dsonar.sources=. -Dsonar.host.url=https://sonarqube.foodgame.fr -Dsonar.login=admin -Dsonar.password=admin"
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
|
|
+// withSonarQubeEnv('FatboarSonar')
|
|
|
|
|
+// {
|
|
|
|
|
+// // If you have configured more than one global server connection, you can specify its name
|
|
|
|
|
+// //sh "${scannerHome}/bin/sonar-scanner -Dsonar.login=admin -Dsonar.password=admin" }
|
|
|
|
|
+// sh "${scannerHome}/bin/sonar-scanner -Dsonar.projectKey=Fatboar_project -Dsonar.sources=. -Dsonar.host.url=https://sonarqube.foodgame.fr -Dsonar.login=admin -Dsonar.password=admin"
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|