代码拉取完成,页面将自动刷新
# 定义三个阶段
stages:
- build
- package
- deploy-k8s
# 定义个变量, 指定maven下载的jar包存放的位置
variables:
# MAVEN_OPTS: "-Dmaven.repo.local=/root/.m2/repository"
APP_RELEASE_NAME: $CI_PROJECT_NAME
APP_REGISTRY_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
#services:
# - name: docker:dind
build:
stage: build
image: maven:3-jdk-8
tags:
- build-runner
script:
- cd web-parsing-engine
- mvn clean package -e -DskipTests
- cd ../web-parsing-book
- mvn clean package -e -DskipTests
- cd ../
artifacts:
expire_in: 1h
paths:
- web-parsing-engine/target/*.jar
- web-parsing-engine/target/classes
- web-parsing-book/target/*.jar
- web-parsing-book/target/classes
package:
stage: package
image: docker:latest
tags:
- build-runner
script:
- echo Build Docker image $APP_REGISTRY_IMAGE
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- cd ./web-parsing-engine && docker build -t $CI_REGISTRY_IMAGE/web-parsing-engine:$CI_COMMIT_REF_SLUG .
- docker push $CI_REGISTRY_IMAGE/web-parsing-engine:$CI_COMMIT_REF_SLUG
- cd ../web-parsing-book && docker build -t $CI_REGISTRY_IMAGE/web-parsing-book:$CI_COMMIT_REF_SLUG .
- docker push $CI_REGISTRY_IMAGE/web-parsing-book:$CI_COMMIT_REF_SLUG
only:
- master
deploy-k8s:
stage: deploy-k8s
image: alpine/helm:3.0.2
tags:
- cluster-k8s-runner
dependencies: []
script:
- echo Deploy Helm release $APP_RELEASE_NAME web-parsing-engine
- helm version
- |
helm upgrade \
--install \
--namespace=web-servers \
--set image.tag=$CI_COMMIT_REF_SLUG \
web-parsing-engine \
./web-parsing-engine/charts/web-parsing-engine
- echo Deploy Helm release $APP_RELEASE_NAME web-parsing-book
- |
helm upgrade \
--install \
--namespace=web-servers \
--set image.tag=$CI_COMMIT_REF_SLUG \
web-parsing-book \
./web-parsing-book/charts/web-parsing-book
only:
- master
when: manual
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。