实现代码推送到gitlab 后gitlab runner (shell) 进行 maven build test 通过后docker build push ,然后通过腾讯云触发器更新 kubernetes
YAML
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
stages: - build - test - deploy maven-build: stage: build script: - git clone ******/commons-java.git - cd commons-java - mvn -DskipTests=true clean install -B - cd ../ - mvn -DskipTests=true clean package -B artifacts: paths: - target/wms.war maven-test: stage: test script: - mvn test -B artifacts: paths: - target/surefire-reports/ build-docker: stage: deploy script: - pwd - ls - export TAG=$CI_COMMIT_SHA-$CI_COMMIT_REF_NAME - echo $TAG - mv target/wms.war wms.war - docker build -t wms:$TAG . - docker tag wms:$TAG ccr.ccs.tencentyun.com/*****/wms:$TAG - docker login -u $DOCKER_USER -p $DOCKER_PASSWORD -e t@aaa.cn ccr.ccs.tencentyun.com - docker push ccr.ccs.tencentyun.com/***/wms:$TAG #k8s-deploy: # image: google/cloud-sdk # stage: deploy # script: # echo "ok" # - 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-sample # - kubectl delete secret registry.gitlab.com # - kubectl create secret docker-registry registry.gitlab.com --docker-server=https://registry.gitlab.com --docker-username=marcolenzo --docker-password=$REGISTRY_PASSWD --docker-email=lenzo.marco@gmail.com # - kubectl apply -f deployment.yml |