Commit a395b57f authored by Administrator's avatar Administrator

更新build.yml

parent fa5cff4a
......@@ -4,18 +4,41 @@ variables:
# 定义 stages
stages:
- pre_test
- pre_prod
- build
pre_test:
only:
- test
script:
- k8sappname=${appname} + '-test'
- image=192.168.123.7:5000/${appname}:test
- springprofile=''
pre_prod:
only:
- master
script:
- k8sappname=${appname} + '-prod'
- image=192.168.123.7:5000/${appname}:prod
- springprofile='--spring.profiles.active=prod'
# 定义 job
build:
only:
- test
- master
stage: build
script:
- cp /home/ubuntu/Dockerfile ./
- echo "appname is ${k8sappname}, port is ${port}, replicas is ${replicas}, nodeName is ${nodeName}, hostNetwork is ${hostNetwork}, springprofile is ${springprofile}"
- mvn -Dmaven.test.skip=true clean package -U
- echo "appname is ${appname}, port is ${port}, replicas is ${replicas}, nodeName is ${nodeName}, hostNetwork is ${hostNetwork}, springprofile is ${springprofile}"
- if [ -d ${appname}-server ]; then cp ${appname}-server/target/*SNAPSHOT.jar app.jar; else cp target/*SNAPSHOT.jar app.jar; fi
- if [ "$appenv" == "prod" ]; then springprofile="--spring.profiles.active=prod"; else springprofile=""; fi
- docker build -t 192.168.123.7:5000/${appname}:latest --no-cache .
- docker push 192.168.123.7:5000/${appname}:latest
- python3 /home/ubuntu/k8s-template/deployment.py --appArgs=${springprofile} --appname=${appname} --port=${port} --hostNetwork=${hostNetwork} --nodeName=${nodeName} --image=192.168.123.7:5000/${appname}:latest --replicas=${replicas} > deployment.yaml
- cp /home/ubuntu/Dockerfile ./
- docker build -t ${image} --no-cache .
- docker push ${image}
- docker image prune
- python3 /home/ubuntu/k8s-template/deployment.py --appArgs=${springprofile} --appname=${k8sappname} --port=${port} --hostNetwork=${hostNetwork} --nodeName=${nodeName} --image=${image} --replicas=${replicas} > deployment.yaml
- kubectl apply -f deployment.yaml
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment