Инструменты пользователя

Инструменты сайта


develop:gitlab

GitLab

Общее

:!: Установка

Советуют установку доп компонентов

yum install curl policycoreutils-python postfix
apt install curl openssh-server ca-certificates
 # Установка репозитория через скрипт
 # Отличаются **gitlab-ce** и **gitlab-еe**- бесплатная и коммерческая с-но
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
 
 # Далее ставим из пакета
apt install gitlab-ce
 
 # Такой вариант тоже должен работать, чтобы не пересобирать после задания адреса
# EXTERNAL_URL="http://gitlab.mysite.ru" yum install gitlab-ee

Для указания адреса по которому будет доступен сервис

external_url 'http://gitlab.mysite.ru' => /etc/gitlab/gitlab.rb

Утилита управления gitlab-ctl, (status/start/restart/stop/kill/service-list…)
GitLab ставится с целым набором нужного себе софта, в т.ч. postgres, prometheus, nginx и т.д.

:!: Использовать другую инсталляцию веб сервера

Процедура описана здесь
Рассматриваем использование Apache
В файле /etc/gitlab/gitlab.rb

nginx['enable'] = false
 
web_server['external_users'] = ['www-data']
gitlab_workhorse['listen_network'] = "tcp"
gitlab_workhorse['listenUmask'] = "0"
gitlab_workhorse['listen_addr'] = "127.0.0.1:8181"
gitlab_workhorse['authBackend'] = "http://127.0.0.1:8080"

Включаем модули apache a2enmod proxy, rewrite, proxy_http
Создаем и включаем виртуальный хост

# This configuration has been tested on GitLab 8.2
# Note this config assumes unicorn is listening on default port 8080 and
# gitlab-workhorse is listening on port 8181. To allow gitlab-workhorse to
# listen on port 8181, edit /etc/gitlab/gitlab.rb and change the following:
#
# gitlab_workhorse['listen_network'] = "tcp"
# gitlab_workhorse['listen_addr'] = "127.0.0.1:8181"
#
#Module dependencies
# mod_rewrite
# mod_proxy
# mod_proxy_http
<VirtualHost *:80>
  ServerName <my-site>
  ServerSignature Off
 
  ProxyPreserveHost On
 
  # Ensure that encoded slashes are not decoded but left in their encoded state.
  # http://doc.gitlab.com/ce/api/projects.html#get-single-project
  AllowEncodedSlashes NoDecode
 
  <Location />
    # New authorization commands for apache 2.4 and up
    # http://httpd.apache.org/docs/2.4/upgrading.html#access
    Require all granted
 
    #Allow forwarding to gitlab-workhorse
    ProxyPassReverse http://127.0.0.1:8181
    ProxyPassReverse http://<my-site>/
  </Location>
 
  # Apache equivalent of nginx try files
  # http://serverfault.com/questions/290784/what-is-apaches-equivalent-of-nginxs-try-files
  # http://stackoverflow.com/questions/10954516/apache2-proxypass-for-rails-app-gitlab
  RewriteEngine on
 
  #Forward all requests to gitlab-workhorse except existing files like error documents
  RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f [OR]
  RewriteCond %{REQUEST_URI} ^/uploads/.*
  RewriteRule .* http://127.0.0.1:8181%{REQUEST_URI} [P,QSA,NE]
 
  # needed for downloading attachments
  DocumentRoot /opt/gitlab/embedded/service/gitlab-rails/public
 
  #Set up apache error documents, if back end goes down (i.e. 503 error) then a maintenance/deploy page is thrown up.
  ErrorDocument 404 /404.html
  ErrorDocument 422 /422.html
  ErrorDocument 500 /500.html
  ErrorDocument 502 /502.html
  ErrorDocument 503 /503.html
 
  # Debian and CentOS distribution defaults provided below
  LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b" common_forwarded
 
  #For CentOS distributions use
  #ErrorLog /var/log/httpd/logs/<my-site>_error.log
  #CustomLog /var/log/httpd/logs/<my-site>_forwarded.log common_forwarded
  #CustomLog /var/log/httpd/logs/<my-site>_access.log combined env=!dontlog
  #CustomLog /var/log/httpd/logs/<my-site>.log combined
 
  #For Debian distributions use
  ErrorLog /var/log/apache2/<my-site>_error.log
  CustomLog /var/log/apache2/<my-site>_forwarded.log common_forwarded
  CustomLog /var/log/apache2/<my-site>_access.log combined env=!dontlog
  CustomLog /var/log/apache2/<my-site>.log combined
</VirtualHost>

Удаление
т.к. вместе с ним ставится много всякого, простое удаление не особо почистило, помогло (вроде) несколько команд:

rpm -e gitlab-ce / apt purge gitlab-ce
 
find / -name gitlab | xargs rm -rf
 
 # Просмотр
ps aux | grep gitlab
:!: Интеграция с jenkins

В дженкинсе создан спец пользователь

В проект добавлен пользователь дженкинса, мейнтейнером

вкладка "Webhooks", выбрана галочка Trigger -> push events и Enable ssl
в интеграциях, включен дженкинс, указан url дженкинса, пользователь, название проекта

В проекте генерируем токен доступа, добавляем ему API, галочка в разрешениях, задаем имя

после этого, в участниках проекта добавляется пользователь, с этим именем

В дженкинсе, создаем запись кредлов, с таким же названием

выбираем тип "GitLab API token", название задаем точно такое же

В джобе выбран «GitLab Connections», созданный пользователь дженкинса

и выбрана "Use alternative credentials", тут указан токен из проекта

в пайплайне выполняются джобы

эти джобы транслиются на дженкинс джобы
в качестве раннеров должна выступать джобы дженкинса
 
develop/gitlab.txt · Последнее изменение: 2023/08/01 04:40 — admin