Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- image: docker:latest
- image: docker:latest
- services:
- - docker:dind
- variables:
- DOCKER_DRIVER: overlay
- SPRING_PROFILES_ACTIVE: gitlab-ci
- # TIME: ""
- # BRANCH: ""
- # REC_BUILD_NAME: ""
- TIME: "timex"
- BRANCH: "branchx"
- DEV_BUILD_NAME: "DEV_APP_x"
- stages:
- - preparation
- - build
- - package
- - deploy
- - manual_rec_build
- - manual_rec_package
- job_preparation:
- stage: preparation
- script:
- - echo ${TIME}
- - export TIME=$(date +%Y%m%d%H%M)
- - "BRANCH=$(echo $CI_BUILD_REF_SLUG | sed 's/[^[[:alnum:]]/_/g')"
- - "DEV_BUILD_NAME=DEV_APP_${BRANCH}_${TIME}"
- - echo ${TIME}
- maven-build:
- image: maven:3-jdk-8
- stage: build
- script:
- - echo ${TIME}
- - "mvn package -B"
- artifacts:
- paths:
- - target/*.jar
- only:
- - merge-requests
- - /^feature/sprint.*$/
- - /^DEV_.*$/
- # when: manual
- docker-build:
- stage: package
- script:
- - echo ${TIME}
- - docker build -t registry.gitlab.com/mourad.sellam/actuator-simple .
- - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.gitlab.com
- - docker push registry.gitlab.com/mourad.sellam/actuator-simple
- only:
- - merge-requests
- - /^feature/sprint.*$/
- - /^DEV_.*$/
- when: manual
- k8s-deploy-production:
- image: google/cloud-sdk
- stage: deploy
- script:
- - echo ${TIME}
- - echo "$GOOGLE_KEY" > key.json
- - gcloud auth activate-service-account --key-file key.json
- - gcloud config set compute/zone europe-west1-c
- - gcloud config set project actuator-sample
- - gcloud config set container/use_client_certificate True
- - gcloud container clusters get-credentials actuator-example
- - kubectl delete secret registry.gitlab.com
- - 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
- - kubectl apply -f deployment.yml --namespace=production
- environment:
- name: production
- url: https://example.production.com
- when: manual
- job_manual_rec_build:
- job_manual_rec_package:
- stage: manual_rec_package
- variables:
- script:
- - echo ${TIME}
- - echo ${DEV_BUILD_NAME}
- - docker build -t registry.gitlab.com/mourad.sellam/actuator-simple:${DEV_BUILD_NAME} .
- - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.gitlab.com
- - docker push registry.gitlab.com/mourad.sellam/actuator-simple
Add Comment
Please, Sign In to add comment