Commit 8fd87d36 authored by Administrator's avatar Administrator

更新build.yml

parent f88e2591
......@@ -4,41 +4,28 @@ variables:
# 定义 stages
stages:
- init
- pre_test
- pre_prod
- build
init:
stage: init
script:
- cat /dev/null > ${appname}.env
pre_test:
stage: pre_test
extend: build
only:
- test
script:
- echo "k8sappname=${appname}-test" >> ${appname}.env
- echo "image=192.168.123.7:5000/${appname}:test" >> ${appname}.env
- echo "springprofile=''" >> ${appname}.env
- cat ${appname}.env
artifacts:
paths:
- ${appname}.env
- k8sappname="${appname}-test"
- image=192.168.123.7:5000/${appname}:test
- springprofile=''
- echo ${k8sappname}${image}${springprofile}
pre_prod:
stage: pre_prod
extend: build
only:
- master
script:
- echo "k8sappname=${appname}-prod" >> ${appname}.env
- echo "image=192.168.123.7:5000/${appname}:prod" >> ${appname}.env
- echo "springprofile='--spring.profiles.active=prod'" >> ${appname}.env
- cat ${appname}.env
artifacts:
paths:
- ${appname}.env
- k8sappname="${appname}-prod"
- image=192.168.123.7:5000/${appname}:prod
- springprofile='--spring.profiles.active=prod'
- echo ${k8sappname}${image}${springprofile}
#定义 job
......@@ -49,11 +36,10 @@ build:
stage: build
script:
- source ${appname}.env
- 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
- if [ -d ${appname}-server ]; then cp ${appname}-server/target/*SNAPSHOT.jar app.jar; else cp target/*SNAPSHOT.jar app.jar; fi
- echo "appname is ${k8sappname}, port is ${port}, replicas is ${replicas}, nodeName is ${nodeName}, hostNetwork is ${hostNetwork}, springprofile is ${springprofile}"
- cp /home/ubuntu/Dockerfile ./
- docker build -t ${image} --no-cache .
- docker push ${image}
......
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