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 .


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM