提交 53a05cab 作者: 杨大同

增加新文件

上级 aa4ba263
流水线 #44565 已取消 于阶段
in 0 秒
stages:
- sonar
- build
- deploy
cache:
paths:
- node_modules/
variables:
PORT: "8009"
PRED_DOMAIN: "listdome"
PROD_DOMAIN: ""
KUBECONFIG: /etc/deploy/config
LAN_REPO: registry-vpc.cn-beijing.aliyuncs.com
WAN_REPO: registry.cn-beijing.aliyuncs.com
DEV_REPO: qianjia_dev
PRED_REPO: qianjia_pred
PROD_REPO: qianjia_prod
# dev分支
sonar_check_job:
image: registry.cn-beijing.aliyuncs.com/qianjia2018/qianjia_dev:sonar1
stage: sonar
before_script:
- CONTAINER_NAME=`echo $CI_PROJECT_NAME | tr 'A-Z' 'a-z'| tr '_' '-'`
script:
- /opt/sonar-runner-2.4/bin/sonar-runner -Dsonar.projectName=$CONTAINER_NAME -Dsonar.projectKey=$CONTAINER_NAME -Dsonar.projectVersion=1.0 -Dsonar.sources=. -Dsonar.language=js -Dsonar.java.binaries=./*
allow_failure: true
tags:
- sonarqube-200
only:
- dev
build_push_image_dev_job:
image: registry-vpc.cn-beijing.aliyuncs.com/qianjia2018/qianjia_public:mvn-docker-kube
stage: build
before_script:
- docker login --username=$USERNAME --password=$PASSWORD registry-vpc.cn-beijing.aliyuncs.com
- CONTAINER_NAME=`echo $CI_PROJECT_NAME | tr 'A-Z' 'a-z'| tr '_' '-'`
- TAG=`expr substr $CI_COMMIT_SHA 1 8`
script:
- docker build -t $LAN_REPO/$DEV_REPO/$CONTAINER_NAME:$TAG -f Dockerfile-dev .
- docker push $LAN_REPO/$DEV_REPO/$CONTAINER_NAME:$TAG
tags:
- k8s
only:
- dev
when: on_success
deploy_to_dev_job:
stage: deploy
before_script:
- CONTAINER_NAME=`echo $CI_PROJECT_NAME | tr 'A-Z' 'a-z'| tr '_' '-'`
- TAG=`expr substr $CI_COMMIT_SHA 1 8`
script:
- bash ~/.local/bin/f200.sh $CONTAINER_NAME $PORT 80 $WAN_REPO/$DEV_REPO/$CONTAINER_NAME:$TAG guojia 192.168.10.200
tags:
- ssh-deploy
only:
- dev
when: on_success
# release分支
build_push_image_pred_job:
image: registry-vpc.cn-beijing.aliyuncs.com/qianjia2018/qianjia_public:mvn-docker-kube
stage: build
before_script:
- docker login --username=$USERNAME --password=$PASSWORD registry-vpc.cn-beijing.aliyuncs.com
- CONTAINER_NAME=`echo $CI_PROJECT_NAME | tr 'A-Z' 'a-z'| tr '_' '-'`
- TAG=`expr substr $CI_COMMIT_SHA 1 8`
script:
- docker build -t $LAN_REPO/$PRED_REPO/$CONTAINER_NAME:$TAG -f Dockerfile-pred .
- docker push $LAN_REPO/$PRED_REPO/$CONTAINER_NAME:$TAG
tags:
- k8s
only:
- release
when: on_success
deploy_to_pred_job:
image: registry-vpc.cn-beijing.aliyuncs.com/qianjia2018/qianjia_public:mvn-docker-kube
stage: deploy
before_script:
- CONTAINER_NAME=`echo $CI_PROJECT_NAME | tr 'A-Z' 'a-z'| tr '_' '-'`
- TAG=`expr substr $CI_COMMIT_SHA 1 8`
script:
- mkdir -p /etc/deploy
- echo $PRED_CONFIG |base64 -d > $KUBECONFIG
- sed -i s/APPNAME/$CONTAINER_NAME/g deployment-pred.yaml
- sed -i s/NAMESPACE/$PRED_REPO/g deployment-pred.yaml
- sed -i s/CONPORT/$PORT/g deployment-pred.yaml
- sed -i s/TAG/$TAG/g deployment-pred.yaml
- sed -i s/DOMAIN/$PRED_DOMAIN/g deployment-pred.yaml
- kubectl apply -f deployment-pred.yaml
tags:
- k8s
only:
- release
when: on_success
# master分支
build_push_image_prod_job:
image: registry-vpc.cn-beijing.aliyuncs.com/qianjia2018/qianjia_public:mvn-docker-kube
stage: build
before_script:
- docker login --username=$USERNAME --password=$PASSWORD registry-vpc.cn-beijing.aliyuncs.com
- CONTAINER_NAME=`echo $CI_PROJECT_NAME | tr 'A-Z' 'a-z'| tr '_' '-'`
- TAG=`expr substr $CI_COMMIT_SHA 1 8`
script:
- docker build -t $LAN_REPO/$PROD_REPO/$CONTAINER_NAME:$TAG -f Dockerfile-prod .
- docker push $LAN_REPO/$PROD_REPO/$CONTAINER_NAME:$TAG
tags:
- k8s
only:
- master
when: on_success
deploy_to_prod_job:
image: registry-vpc.cn-beijing.aliyuncs.com/qianjia2018/qianjia_public:mvn-docker-kube
stage: deploy
before_script:
- CONTAINER_NAME=`echo $CI_PROJECT_NAME | tr 'A-Z' 'a-z'| tr '_' '-'`
- TAG=`expr substr $CI_COMMIT_SHA 1 8`
script:
- mkdir -p /etc/deploy
- echo $PROD_CONFIG |base64 -d > $KUBECONFIG
- sed -i s/APPNAME/$CONTAINER_NAME/g deployment-prod.yaml
- sed -i s/NAMESPACE/$PROD_REPO/g deployment-prod.yaml
- sed -i s/CONPORT/$PORT/g deployment-prod.yaml
- sed -i s/TAG/$TAG/g deployment-prod.yaml
- sed -i s/DOMAIN/$PROD_DOMAIN/g deployment-prod.yaml
- kubectl apply -f deployment-prod.yaml
tags:
- k8s
only:
- master
when: on_success
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论