Jenkinsfile 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. node{
  2. stage('checkout'){
  3. deleteDir()
  4. checkout scm
  5. }
  6. stage('Stop Container'){
  7. //sh 'docker ps | grep "workflow_" -v | awk -F " " \'{if(NR>1)print $1}\' | xargs docker killdo | xargs docker rm || true'
  8. //sh 'docker system prune -f'
  9. sh 'docker ps | grep "workflow_" -v | awk -F " " \'{ if(NR>1) print $1}\' |xargs docker kill |xargs docker rm || true'
  10. sh 'docker system prune -f'
  11. }
  12. /*stage('Build Container')
  13. {
  14. imageApache=docker.build('server-apache-dev', '--no-cache -f build/docker/apache/Dockerfile .')
  15. imageSql=docker.build('server-mysql-dev', '--no-cache -f build/docker/mysql/Dockerfile .')
  16. containerMysql=imageSql.run('--name server-mysql-dev')
  17. containerApache=imageApache.run('-p 8080:80 --link server-mysql-dev:mysql')
  18. }*/
  19. def imageApache = stage("Build apache preprod")
  20. {
  21. 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 .")
  22. }
  23. stage("Run Container apache preprod")
  24. {
  25. containerApache=imageApache.run("--name server-apache-preprod --link server-mysql-preprod:mysql --network=web")
  26. }
  27. /*stage('Waiting Container'){
  28. waitUntil{
  29. try{
  30. sh "docker exec ${containerApache.id} php -v"
  31. return true
  32. } catch(Exception $e){
  33. return false
  34. }
  35. }
  36. }*/
  37. stage('stage 1bis'){
  38. sh 'docker -v'
  39. sh 'docker ps'
  40. }
  41. stage('stage 2bis'){
  42. sh 'ls -ls'
  43. }
  44. stage('SonarQube analysis') {
  45. def scannerHome = tool 'sonar_scanner';
  46. withSonarQubeEnv('FatboarSonar')
  47. {
  48. // If you have configured more than one global server connection, you can specify its name
  49. //sh "${scannerHome}/bin/sonar-scanner -Dsonar.login=admin -Dsonar.password=admin" }
  50. sh "${scannerHome}/bin/sonar-scanner -Dsonar.projectKey=Fatboar_project -Dsonar.sources=. -Dsonar.host.url=https://sonarqube.foodgame.fr -Dsonar.login=admin -Dsonar.password=admin"
  51. }
  52. }
  53. }