更新.gitlab-ci.yml文件

This commit is contained in:
杨永强
2021-10-27 07:33:17 +00:00
parent 7da0bada3b
commit 4233c6eed0

59
.gitlab-ci.yml Normal file
View File

@@ -0,0 +1,59 @@
#定义变量
variables:
#定义克隆的路径 $CI_BUILDS_DIR 为 runners.builds_dir 设置的路径
GIT_CLONE_PATH: $CI_BUILDS_DIR/server/link
#git ssh 地址
GITLAB_SSH: git@git.mesalab.cn:yangyongqiang/yyq_test.git
# 指定git获取代码的方式clone,fetch,none
GIT_STRATEGY: clone
#在作业之前执行的脚本或命令
before_script:
- echo "环境部署操作"
# 创建对应目录
- mkdir -p $GIT_CLONE_PATH
- cd $GIT_CLONE_PATH
#在作业之后执行的脚本或命令
after_script:
#配置目录的用户权限
- chown -R www:www $GIT_CLONE_PATH
# 全局定义流水线阶段pipeline
stages:
- build
develop_build:
stage: build
#需要执行的shell脚本
script:
- echo "开发服务器环境配置"
- if [ ! -d ".git" ]; then
- git clone -b master $GITLAB_SSH $GIT_CLONE_PATH --depth 1
- else
- git stash
- fi
- git pull
only:
# 指定分支
- master
tags:
# 指定执行作业的runner
- developRunner
master_build:
stage: build
script:
- echo "正式服务器环境配置"
- if [ ! -d ".git" ]; then
- git clone -b master $GITLAB_SSH $GIT_CLONE_PATH --depth 1
- else
- git stash
- fi
- git pull
only:
- master
tags:
- masterRunner