docker安装gitlab-runner

docker安装gitlab-runner

docker pull gitlab/gitlab-runner:latest安装gitlab-runner

打开自己搭建的GitLab网站,点击顶栏的Snippets后面的小扳手,再点击左侧列表中Overview中的Runners,在打开的网页下面,可以看到How to setup a shared Runner for a new project行,2是Runners设置时需要指定的URL,3是在设置是的Runners

运行镜像

docker run -d --name gitlab-runner --restart always -v /var/run/docker.sock:/var/run/docker.sock -v /srv/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner:latest

注册gitlab-runner

docker exec -it gitlab-runner gitlab-runner register

Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):输入域名或者服务器ip地址,格式为https://gitlab.com。和token Please enter the gitlab-ci token for this runner:

Please enter the gitlab-ci description for this runner:输入runner描述。

Please enter the gitlab-ci tags for this runner (comma separated):给这个Runner指定tags,稍后也可以在GitLab's UI中修改。

Whether to run untagged builds [true/false]:选择Runner是否接受未指定tags的任务,稍后可修改。默认值为false

Whether to lock the Runner to current project [true/false]: 选择是否为当前项目锁定Runner,可修改。通常用于被指定为某个项目的Runner,默认值为true

Please enter the executor: docker, shell, virtualbox, kubernetes, docker-ssh, parallels, ssh, docker+machine, docker-ssh+machine: 选择Runner executor(Runner执行器),使用shell,使用gitlab-runner环境。
重启容器docker restart gitlab-runner

修改配置文件docker exec -it name vim /etc/gitlab-runner/config.toml

pep8检查环境配置

进去docker容器环境docker exec -it name /bin/bashname就是容器的名称,如果没有启动容器,会报错。

安装python-pipapt-get update && apt-get install python-pip -y

使用pip安装flake8pep8pip install pep8 flake8,第一次使用pip可能需要更新pip install --upgrade pip
更改pip源,提高下载速度。编辑$HOME/.pip/pip.conf,添加内容:
[global] index-url = https://mirrors.ustc.edu.cn/pypi/web/simple format = columns
如果文件不存在,创建新文件或目录。

在项目中使用flake8进行风格检查

需要在项目根目录下添加两个文件.flake8.gitlab-ci.yml,提交到gitlab上。

添加.flake8配置文件

[flake8] ignore = W292 exclude = *migrations*, # python related *.pyc, .git, __pycache__, max-line-length=120 max-complexity=12 format=pylint show_source = True statistics = True count = True

说明

注意, 在.flake8里面不要带中文
ignore = 忽略错误类型
exclude = 不检查的文件正则列表
max-line-length = 单行最大字符数120
max-complexity = 代码复杂度等级
format = 展示格式
show_source = 显示源代码
statistics = 展示统计
count = 展示总错误数

添加.gitlab-ci.yml配置文件

before_script:
- echo "Python静态代码检查..."
pep8:
script:
- flake8 .
posted @   zzhaoleiの博客  阅读(7661)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
点击右上角即可分享
微信分享提示