咸鱼

咸鱼是以盐腌渍后,晒干的鱼

0%

gitlab关闭Pipeline

一路从10.5.5 升级到 12.9.5 后,发现项目默认启用了CI/CD Pipeline流水线,如果项目有 git push 就会触发Pipeline自动构建,构建失败会发邮件通知。
Pipeline这个东西暂时还没有研究过,【有兴趣请参考】,但我项目中无需自行自动构建和部署,所以暂时不需要,想关掉它。

Gitlab-CI使用入门

每个项目关闭

在Gitlab网页端项目的 设置 -> 通用 -> 可见性、项目功能、权限 可以关闭 Pipeline。

在项目配置文件中禁用

在项目的根目录创建一个 .gitlab-ci.yml 配置文件,在它里面设置暂时禁用某个作业,而不将其删除。

作业名称以点(.)开始,GitLab CI/CD不会处理它

1
2
3
.hidden_job:
script:
- run test

修改默认值

1
2
3
4
$ vim /etc/gitlab/gitlab.rb
gitlab_rails['gitlab_default_projects_features_builds'] = false

$ gitlab-ctl reconfigure

这仅仅对新建项目有效,新建项目默认不开启Pipeline,但仍然可以通过 设置 -> 通用 -> 可见性、项目功能、权限 开启 Pipeline。

Pipeline

在项目中根目录创建一个 .gitlab-ci.yml ,可以配置构建任务,gitlab有很多模板参考,比如Python

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# This file is a template, and might need editing before it works on your project.
# Official language image. Look for the different tagged releases at:
# https://hub.docker.com/r/library/python/tags/
image: python:latest

# Change pip's cache directory to be inside the project directory since we can
# only cache local items.
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"

# Pip's cache doesn't store the python packages
# https://pip.pypa.io/en/stable/reference/pip_install/#caching
#
# If you want to also cache the installed packages, you have to install
# them in a virtualenv and cache it as well.
cache:
paths:
- .cache/pip
- venv/

before_script:
- python -V # Print out python version for debugging
- pip install virtualenv
- virtualenv venv
- source venv/bin/activate

test:
script:
- python setup.py test
- pip install tox flake8 # you can also use tox
- tox -e py36,flake8

run:
script:
- python setup.py bdist_wheel
# an alternative approach is to install and run:
- pip install dist/*
# run the command here
artifacts:
paths:
- dist/*.whl

pages:
script:
- pip install sphinx sphinx-rtd-theme
- cd doc ; make html
- mv build/html/ ../public/
artifacts:
paths:
- public
only:
- master