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 .

转载于:https://www.cnblogs.com/zzhaolei/p/11063345.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值