跳到主要内容

实践:CI-CD-GitLab流水线(扩展)

实践:CI-CD-GitLab流水线(扩展)

image-20230702065734629

image-20230702065743210

image-20230702065757662

image-20230702065815028

image-20230702065824332

目录

[toc]

1. 流水线运行效果

持续集成

tstmp_20230702065902

制品管理

tstmp_20230702065914

持续部署

tstmp_20230702065925

tstmp_20230702065932

2. 流水线代码分析

导入模板库

include:
- project: 'devops4/devops4-gitlablib-service'
ref: main
file:
- '/jobs/CI.yaml'
- '/jobs/CD.yaml'

流水线运行条件

workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "web"
when: always
- if: $CI_COMMIT_BEFORE_SHA == "0000000000000000000000000000000000000000"
when: never
- when: always

设置运行变量

variables:
GIT_CHECKOUT: "false" ## 全局关闭作业代码下载
BUILD_SHELL: "sh -x build.sh" ## 构建命令
# TEST_SHELL: "mvn test " ## 测试命令
# ARTIFACT_PATH: "target/*jar" ## 制品路径
# TEST_REPORTS: "target/surefire-reports/TEST-*.xml" ##测试报告
RUNNER_TAG: "builder"
PROJECT_TYPE: "java"
DEPLOY_HOSTS: "192.168.1.121 192.168.1.122"
TARGET_DIR: "/opt"
RUN_TYPE: "CI"
PORT: "8888"

流水线阶段

stages:
- build
- test
- pushartifact
- pullartifact
- deploy
- healthCheck

流水线作业

pipelineInit:
extends:
- .pipelineInit

cibuild:
extends:
- .cibuild

# ciscan:
# extends:
# - .codescan

pushartifact:
extends:
- .pushartifact

pullartifact:
extends:
- .pullartifact

# dockerbuild:
# extends:
# - .dockerbuild

deploy:
extends:
- .deploy

healthCheck:
extends:
- .healthCheck

关于我

我的博客主旨:

  • 排版美观,语言精炼;
  • 文档即手册,步骤明细,拒绝埋坑,提供源码;
  • 本人实战文档都是亲测成功的,各位小伙伴在实际操作过程中如有什么疑问,可随时联系本人帮您解决问题,让我们一起进步!

🍀 微信二维码 x2675263825 (舍得), qq:2675263825。

image-20230107215114763

🍀 微信公众号 《云原生架构师实战》

image-20230107215126971

🍀 个人博客站点

http://47.97.48.237/ (即将上线域名:onedayxyy.cn)

image-20230917111843405

🍀 语雀

https://www.yuque.com/xyy-onlyone

image-20230912072007284

🍀 csdn https://blog.csdn.net/weixin_39246554?spm=1010.2135.3001.5421

image-20230107215149885

🍀 知乎 https://www.zhihu.com/people/foryouone

image-20230107215203185

最后

好了,关于本次就到这里了,感谢大家阅读,最后祝大家生活快乐,每天都过的有意义哦,我们下期见!