前提:
新建GitLab 项目,可参考我另一篇博客
GitLab -- 创建项目_DGH2430284817的博客-CSDN博客
安装配置好Runner,可参考我另一篇博客:
GitLab -- 安装和配置Runner_DGH2430284817的博客-CSDN博客
创建.gitlab-ci.yml 文件,内容可以参考下面,随意一些,用来测试,这个文件放到git库的根目录
# 本次构建的阶段:build package
stages:
- build
- package
# 构建 Job
build:
stage: build
#注册runner时设置的tag
tags:
- diaoTag
script:
- echo "=============编译构建任务=============="
# 打包
package:
stage: package
tags:
- diaoTag
script:
- echo "==============打包任务============="
提交代码,不熟悉linux 上拉取和提交代码操作的可以参考我另一篇博客:
GitLab -- linux拉取和提交代码_DGH2430284817的博客-CSDN博客
git status
git add .gitlab-ci.yml
git commit -m "cicd test"
git push -u origin master
提交完代码后,可在GitLab 网页上看到这次提交的CICD信息,
点击 Stags 下的步骤,可查看具体操作日志