Commit 8fd87d36 authored by Administrator's avatar Administrator

更新build.yml

parent f88e2591
...@@ -4,41 +4,28 @@ variables: ...@@ -4,41 +4,28 @@ variables:
# 定义 stages # 定义 stages
stages: stages:
- init
- pre_test
- pre_prod
- build - build
init:
stage: init
script:
- cat /dev/null > ${appname}.env
pre_test: pre_test:
stage: pre_test extend: build
only: only:
- test - test
script: script:
- echo "k8sappname=${appname}-test" >> ${appname}.env - k8sappname="${appname}-test"
- echo "image=192.168.123.7:5000/${appname}:test" >> ${appname}.env - image=192.168.123.7:5000/${appname}:test
- echo "springprofile=''" >> ${appname}.env - springprofile=''
- cat ${appname}.env - echo ${k8sappname}${image}${springprofile}
artifacts:
paths:
- ${appname}.env
pre_prod: pre_prod:
stage: pre_prod extend: build
only: only:
- master - master
script: script:
- echo "k8sappname=${appname}-prod" >> ${appname}.env - k8sappname="${appname}-prod"
- echo "image=192.168.123.7:5000/${appname}:prod" >> ${appname}.env - image=192.168.123.7:5000/${appname}:prod
- echo "springprofile='--spring.profiles.active=prod'" >> ${appname}.env - springprofile='--spring.profiles.active=prod'
- cat ${appname}.env - echo ${k8sappname}${image}${springprofile}
artifacts:
paths:
- ${appname}.env
#定义 job #定义 job
...@@ -49,11 +36,10 @@ build: ...@@ -49,11 +36,10 @@ build:
stage: build stage: build
script: script:
- source ${appname}.env - 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 - 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 - 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 ./ - cp /home/ubuntu/Dockerfile ./
- docker build -t ${image} --no-cache . - docker build -t ${image} --no-cache .
- docker push ${image} - 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