GITLAB配置CI教程

一、gitlab runner下载安装

1、研发网下载安装包【172.20.191.53已经安装过了,不用再安装了,可以直接到第三步】

下载gitlab安装包

wget https://packages.gitlab.com/runner/gitlab-runner/packages/fedora/32/gitlab-runner-12.1.0-1.x86_64.rpm

​

2、安装【172.20.191.53已经安装过了,不用再安装了,可以直接到第三步】

安装

rpm -i gitlab-runner-12.1.0-1.x86_64.rpm

3、获取token【复制图中步骤4的token,同时复制图中的URL】

4、注册

注册

sudo gitlab-runner register

a、1和2使用刚才获取的URL和TOKEN

b、4表示TAG,设置好需要记住,比如你这个是x86_64_linux,后续在写ci脚本的时候TAG需要和这个对应;

c、6表示的是默认运行ci的服务器地址,8.9这个可以使用个人账号或者公共账号都可;

d、上述图片中没有标记数字的步骤,可以使用默认值直接enter;

5、gitlab的项目和runner是否绑定成功判断

重复第三步的路径,查看有如下的内容,即配置成功。

6、CI脚本配置

gitlab仓库有一些脚本的模板,可以自己选择,当然进一步学习高阶用法可以在网上找相关资料,或者从其他配置好的项目中去抄,最终目的就是为了创建一个

.gitlab-ci.yml 的文件。

学习教程:极狐GitLab CI/CD 入门 | 极狐GitLab

7、成果展示

如果所有的配置正确,并完成了ci脚本的编写,就可以执行流水线的任务,如图

二、Q&A

1、第二次执行ci出错

已知问题经验

Using
Shell executor...
Running on localhost.localdomain...
Reinitialized existing Git repository in
/home/gitlab-runner/(...)/.git/
Clean repository
Fetching changes with git depth set to 50...
fatal: remote origin already exists.
fatal: git fetch-pack: expected shallow list
ERROR: Job failed: exit status 1

解决方案:

解决方案

Options to fix:
 1、Upgrade to a newer version of git on the runner.
 2、In .gitlab-ci.yml, use the option to git clone:
variables:
  GIT_STRATEGY: clone

 3、Configure Gitlab, change Git strategy for pipelines of the project to "git
     clone".
          3.1. In the Gitlab web gui,
          3.2. go to your project,
          3.3. then: "Settings -> CI / CD -> General
     pipelines".
          3.4. Change the options for:
  "Git strategy for pipelines" to: "git clone"
  "Git shallow clone" to: 0

相关推荐

  1. gitlab-ci_cd语法CICD

    2024-07-09 16:52:04       32 阅读
  2. .gitlab-ci.yml文件参数配置和使用

    2024-07-09 16:52:04       48 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-09 16:52:04       49 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-09 16:52:04       53 阅读
  3. 在Django里面运行非项目文件

    2024-07-09 16:52:04       42 阅读
  4. Python语言-面向对象

    2024-07-09 16:52:04       53 阅读

热门阅读

  1. 编写简单的Ansible Playbook

    2024-07-09 16:52:04       25 阅读
  2. VSCode + 阿里云OSS + 图床插件Picgo

    2024-07-09 16:52:04       31 阅读
  3. 【Hive实战】HiveMetaStore的指标采集告警

    2024-07-09 16:52:04       18 阅读
  4. 设计模式简单示例

    2024-07-09 16:52:04       23 阅读
  5. CSS里的几个小知识

    2024-07-09 16:52:04       30 阅读
  6. 社交媒体原生应用开发:Facebook的创新之路

    2024-07-09 16:52:04       33 阅读
  7. Gunicorn+Flask+Docker初体验

    2024-07-09 16:52:04       26 阅读
  8. 常用目标检测的格式转换脚本文件txt,json等

    2024-07-09 16:52:04       25 阅读