Guest User

Untitled

a guest
Oct 22nd, 2018
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. image: docker:latest
  2. image: docker:latest
  3. services:
  4. - docker:dind
  5.  
  6. variables:
  7. DOCKER_DRIVER: overlay
  8. SPRING_PROFILES_ACTIVE: gitlab-ci
  9. # TIME: ""
  10. # BRANCH: ""
  11. # REC_BUILD_NAME: ""
  12. TIME: "timex"
  13. BRANCH: "branchx"
  14. DEV_BUILD_NAME: "DEV_APP_x"
  15.  
  16. stages:
  17. - preparation
  18. - build
  19. - package
  20. - deploy
  21. - manual_rec_build
  22. - manual_rec_package
  23.  
  24. job_preparation:
  25. stage: preparation
  26. script:
  27. - echo ${TIME}
  28. - export TIME=$(date +%Y%m%d%H%M)
  29. - "BRANCH=$(echo $CI_BUILD_REF_SLUG | sed 's/[^[[:alnum:]]/_/g')"
  30. - "DEV_BUILD_NAME=DEV_APP_${BRANCH}_${TIME}"
  31. - echo ${TIME}
  32.  
  33. maven-build:
  34. image: maven:3-jdk-8
  35. stage: build
  36. script:
  37. - echo ${TIME}
  38. - "mvn package -B"
  39. artifacts:
  40. paths:
  41. - target/*.jar
  42. only:
  43. - merge-requests
  44. - /^feature/sprint.*$/
  45. - /^DEV_.*$/
  46. # when: manual
  47.  
  48.  
  49. docker-build:
  50. stage: package
  51. script:
  52. - echo ${TIME}
  53. - docker build -t registry.gitlab.com/mourad.sellam/actuator-simple .
  54. - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.gitlab.com
  55. - docker push registry.gitlab.com/mourad.sellam/actuator-simple
  56. only:
  57. - merge-requests
  58. - /^feature/sprint.*$/
  59. - /^DEV_.*$/
  60. when: manual
  61.  
  62. k8s-deploy-production:
  63. image: google/cloud-sdk
  64. stage: deploy
  65. script:
  66. - echo ${TIME}
  67. - echo "$GOOGLE_KEY" > key.json
  68. - gcloud auth activate-service-account --key-file key.json
  69. - gcloud config set compute/zone europe-west1-c
  70. - gcloud config set project actuator-sample
  71. - gcloud config set container/use_client_certificate True
  72. - gcloud container clusters get-credentials actuator-example
  73. - kubectl delete secret registry.gitlab.com
  74. - kubectl create secret docker-registry registry.gitlab.com --docker-server=https://registry.gitlab.com --docker-username=myUserName--docker-password=$REGISTRY_PASSWD --docker-email=myEmail@gmail.com
  75. - kubectl apply -f deployment.yml --namespace=production
  76. environment:
  77. name: production
  78. url: https://example.production.com
  79. when: manual
  80.  
  81. job_manual_rec_build:
  82.  
  83. job_manual_rec_package:
  84. stage: manual_rec_package
  85. variables:
  86. script:
  87. - echo ${TIME}
  88. - echo ${DEV_BUILD_NAME}
  89. - docker build -t registry.gitlab.com/mourad.sellam/actuator-simple:${DEV_BUILD_NAME} .
  90. - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.gitlab.com
  91. - docker push registry.gitlab.com/mourad.sellam/actuator-simple
Add Comment
Please, Sign In to add comment