zoukankan      html  css  js  c++  java
  • 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 .
    
  • 相关阅读:
    C的联合体和结构体区别
    1_大端模式和小端模式
    1_2017年中兴机试题
    树1---基础
    栈的应用2---后缀表达式
    2 链式存储栈
    2- 栈和队列----之栈
    2) 线性链表
    kaike的FLAGs
    QAQ来自弱鸡的嘲笑
  • 原文地址:https://www.cnblogs.com/zzhaolei/p/11063345.html
Copyright © 2011-2022 走看看