GitLab
Version Control on your Server like GitHub but Open Source!!
Category
How to install
CentOS
CentOS7를 기준으로 아래와 같이 설정한다.
$ sudo yum install openssh-server
$ sudo systemctl enable sshd
$ sudo systemctl start sshd
$ sudo yum install postfix
$ sudo systemctl enable postfix
$ sudo systemctl start postfix
$ sudo firewall-cmd --permanent --add-service=http
$ sudo systemctl reload firewalld
그리고 Omnibus package를 다운로드 받는다.
$ curl -O https://downloads-packages.s3.amazonaws.com/centos-7.0.1406/gitlab-7.7.2_omnibus.5.4.2.ci-1.el7.x86_64.rpm
$ sudo rpm -i gitlab-7.7.2_omnibus.5.4.2.ci-1.el7.x86_64.rpm
필요하다면 설정파일을 수정한다.
서비스를 시작한다.
참고로 CentOS 기준으로 설치되는 위치는 /opt/gitlab/
이다.
Ubuntu
$ sudo apt-get install curl openssh-server ca-certificates postfix
$ curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
$ sudo apt-get install gitlab-ce
$ sudo gitlab-ctl reconfigure
Configuration
Enable HTTPS
기본 설정을 사용하여 HTTPS를 적용하고 싶다면 아래와 같이 external_url
의 프로토콜을 https
로 변경하면 된다.
공개키 위치를 지정하고 싶다면 아래 속성을 사용하면 된다.
# For GitLab
nginx['ssl_certificate'] = "/etc/gitlab/ssl/gitlab.example.crt"
nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/gitlab.example.com.key"
그리고 위의 도메인 이름으로 만들어진 공개 키 인증서 (Public key certificate)를1 아래와 같이 위치시킨다.
새로운 공개키를 OpenSSL#How to create a certificate를 참조하여 작성한다. 간단하게, 아래와 같이 진행할 수 있다.
$ sudo -s
$ cd /etc/gitlab/ssl
$ openssl req -x509 -sha256 -nodes -days 3650 -newkey rsa:2048 -keyout private.key -out certificate.crt
Gitlab in Docker
- Omnibus GitLab documentation > GitLab Docker images
- 머가필요해 :: GitLab in Docker (간편하게 설치하기)
- GitLab Docker로 설치하기
초기 설치시 관리자 ID는 root
이다.
Testing the SMTP configuration
You can verify GitLab's ability to send emails properly using the Rails console. On the GitLab server, execute gitlab-rails console to enter the console. Then, you can enter the following command at the console prompt to cause GitLab to send a test email:
irb(main):003:0> Notify.test_email('[email protected]', 'Message Subject', 'Message Body').deliver_now
How to uninstall
아래와 같이 제거할 수 있다.
# Stop gitlab and remove its supervision process
$ sudo gitlab-ctl uninstall
# Redhat/Centos
$ sudo rpm -e gitlab
# To remove all omnibus-gitlab data use
$ sudo gitlab-ctl cleanse
# To remove all users and groups created by omnibus-gitlab
$ sudo gitlab-ctl remove_users
How to update
- Updating GitLab via omnibus-gitlab
- 후뤼한잉여의 Bravo Hree Life! - GitLab 업그레이드 하기
- 스토브 훌로구 - GitLab 업그레이드 하기
## 실행중인 GitLab 서비스 중단.
$ sudo gitlab-ctl stop unicorn
$ sudo gitlab-ctl stop sidekiq
$ sudo gitlab-ctl stop nginx
## GitLab 백업하기.
sudo gitlab-rake gitlab:backup:create
## GitLab 업그레이드 하기.
sudo yum install gitlab-ce
## GitLab Repository 재설정 및 서버 재시작.
sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart
How to backup
## GitLab 백업하기.
## - /etc/gitlab/gitlab.rb 에 gitlab_rails['backup_path'] 변수에 정의된 경로로 백업데이터가 저장된다.
## - 기본 백업 디렉토리는 /var/opt/gitlab/backups
$ sudo gitlab-rake gitlab:backup:create
(LEGACY!!) 복원은 아래와 같이 진행하면 된다. <del>
$ sudo gitlab-ctl stop unicorn
$ sudo gitlab-ctl stop sidekiq
## Verify
$ sudo gitlab-ctl status
## Next, restore the backup, specifying the timestamp of the backup you wish to restore:
## This command will overwrite the contents of your GitLab database!
$ sudo gitlab-rake gitlab:backup:restore BACKUP=1393513186
## Restart!
$ sudo gitlab-ctl start
</del>
아래와 같이 복원하면 백업 디렉토리의 Timestamp를 확인하여 최신 백업본을 사용하여 복원된다.
## Stop processes that are connected to the database
$ sudo service gitlab stop
## Restore
$ bundle exec rake gitlab:backup:restore RAILS_ENV=production
## Next, restore /home/git/gitlab/.secret if necessary as mentioned above.
## ...
## Restart GitLab:
$ sudo service gitlab restart
WARNING |
참고로 백업과 마이그레이션은 다르다! 백업한 데이터의 버전과 현재 GitLab의 버전이 다르면 정상적으로 복원할 수 없다. |
Restore for Docker image and gitlab-omnibus helm chart
For docker installations, the restore task can be run from host using the command
Creating a branch from issue in GitLab
<issue-number>-issue-description
이라는 이름으로 분기를 만들고 해당 분기를 gitlab에 푸시하면 해당 Issue에 자동으로 연결됩니다. 예를 들어 ID 654에 Issue가 있고 이름이 654-some-feature
인 분기를 만들고 이를 gitlab에 푸시하면 Issue 654에 연결됩니다.
Gitlab은 병합 요청을 생성할 것인지 묻고 병합 요청이 수락되면 문제 654를 종료하는 병합 요청 설명에 Closes #654
를 자동으로 추가합니다.
또한 gitlab의 특정 이슈 페이지로 이동하면 <issue-number>-issue-description
형식의 이름으로 브랜치를 자동으로 생성하는 New Branch 버튼이 표시되어야 합니다.
GitLab 문서의 내용
Prefix a branch name with an issue number to streamline merge request creation. When you create a merge request for a branch with a name beginning with an issue number, GitLab:
- Marks the issue as related. If your project is configured with a default closing pattern, merging this merge request also closes the related issue.
- Copies label and milestone metadata from the issue.
Time tracking
문제 설명 및 댓글 상자에서 빠른 작업(Quick Action)을 사용할 수 있습니다.
-
/estimate
- 예상 시간을 업데이트합니다. -
/spend
- 실제 소요된 시간의 합계를 업데이트합니다.
Auto DevOps
Auto DevOps는 프로그래밍 언어를 감지하고 CI/CD 템플릿을 사용하여 기본 파이프라인을 만들고 실행하여 애플리케이션을 빌드하고 테스트합니다.
그런 다음 앱을 스테이징 및 프로덕션에 배포하도록 배포를 구성하고, 브랜치별로 변경 사항을 미리 볼 수 있도록 검토 앱을 설정할 수 있습니다.
Disable 방법
To enable (or disable) Auto DevOps for all projects:
- On the left sidebar, at the bottom, select Admin.
- Select Settings > CI/CD.
- Check (or uncheck to disable) the box that says Default to Auto DevOps pipeline for all projects.
- Optionally, set up the Auto DevOps base domain which is used for Auto Deploy and Auto Review Apps.
- Select Save changes for the changes to take effect.
Example
-
sudo gitlab-ctl status
- GitLab의 현재 상태를 확인한다.
-
sudo gitlab-rake gitlab:env:info
- GitLab의 버전정보를 확인한다.
GitLab Systems Diagram
GitLab이 사내에서 사용하는 전체 Tech Stack Applications. 완전 리모트 회사는 어떤 솔루션들을 사용하고 있는지 참고하기 좋은 자료. 별도 구글시트에 제품(링크),사용 목적,접근 권한,그룹/비즈니스/기술 오너, 어떤 데이터를 수집하는지, 고객용 or 직원용인지 등을 한눈에 정리
- Finance : Stripe, NetApp, Zuora, ADP, Blackline, Expensify, Clari, Carta, Xactly, Avalara, "CloudExtend: Gdrive for NetSuite", NetSuite
- Sales : Salesforce, Chrous.ai, Clari, OwnBackup, Sertifi
- PeopleOps : Zoom, Gmail, Calendly, Beamy, Lumity, Beeterment, Teleport, Moo, Bonusly, Slack, NexTravel, Crowdin, Will Interactive, CultureAmp, Greenhouse
- Data Team : Data warehouse, Periscope
- Product : GitLab, dev.gitlab, customers.gitlab, license.gitlab, version.gitlab
- Legal : ContractWorks, Conga Contracts, Visual Compliance
- Advertising/Social : PMG, Facebook Advertising, Linked Advertising, Google AdWords, Sprout Social, Tweetdeck, EventBrite, Youtube, Moz Pro
- Marketing : MailChimp, mailgun, Mandrill, Meetup, Disqus, Google Analytics, Google Tag Manager, Cookiebot, shopify, about.gitlab, Zapier, Marketo, Demandbase, Drift, PathFactory, Bizzabo, FunnelCake, Bizible, Enrichment TBD, LeanData, WebEx, Outreach, Point of Reference
- Prospecting & Enrichment : DiscoverOrg, DataFox, LinkedIn Sales Nav, GovWin(PubSec), Lusha (EMEA)
- Meeting Setting Vendors : Dogood, BAO (By Appointment Only)
Troubleshooting
502 error
게이트웨이 역할을 하는 Unicorn이 정상적으로 작동하지 않아 발생되는 문제일 수 있다. 로그파일을 확인하면 아래와 같은 에러 메시지를 확인할 수 있다. 참고로 로그파일은 ./var/log/gitlab/nginx/gitlab_error.log
에 존재한다.
2015/04/08 18:55:26 [error] 32263#0:
*1 connect() to unix:/var/opt/gitlab/gitlab-rails/sockets/gitlab.socket failed
(111: Connection refused) while connecting to upstream,
client: [CLIENT_IPADDRESS],
server: [HOSTNAME], request: "GET / HTTP/1.1",
upstream: "http://unix:/var/opt/gitlab/gitlab-rails/sockets/gitlab.socket:/", host: [HOSTNAME]
Note that on a single-core server it may take up to a minute to restart Unicorn and Sidekiq. Your GitLab instance will give a 502 error until Unicorn is up again. It is also possible to start, stop or restart individual components.
Unicorn supports zero-downtime reloads. These can be triggered as follows:
Note that you cannot use a Unicorn reload to update the Ruby runtime.
또는 아래의 게시물을 확인:
- "502 bad gateway" Gitlab error in nginx server
- connect() failed (111: Connection refused) while connecting to upstream
- 502 error caused by connection refused: (upstream fastcgi, etc) (23 posts)
413 Request Entity Too Large
git push
시 아래와 같은 에러가 발생할 수 있다.
$ git push gitlab
Counting objects: 8549, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (6388/6388), done.
error: RPC failed; HTTP 413 curl 22 The requested URL returned error: 413 Request Entity Too Large
fatal: The remote end hung up unexpectedly
Writing objects: 100% (8549/8549), 69.59 MiB | 136.81 MiB/s, done.
Total 8549 (delta 1833), reused 8549 (delta 1833)
fatal: The remote end hung up unexpectedly
Everything up-to-date
/etc/gitlab/gitlab.rb
파일을 아래와 같이 수정한다.
만약 Proxy서버가 Front-end에 존재한다면 해당 서버에도 클라이언트의 최대 Body 크기를 수정해야 한다.
SSL Verification error
/opt/gitlab/embedded/ssl/certs/cacert.pem
파일에 인증서를 추가하면 된다.
HTTP 413 curl 22 The requested URL returned error
- RPC failed; HTTP 413 curl 22 The requested URL returned error: 413 Request Entity Too Large
- Account and limit settings | GitLab # 413 Request Entity Too Large
- (gitlab) Solving the Error 413
- nginx 업로드 파일 용량 초과 오류 해결 - HTTP 413 client intended to send too large body
Reverseproxy를 사용할 경우, 해당 해당 서버도 함께 수정해야 한다.
gitlab.rb before increasing the max attachment size:
또는 클라이언트에서 업로드 가능한 POST 버퍼 크기를 제한하면 된다.
참고로 nginx를 reverse proxy로 사용할 경우 다음 값을 수정해야 한다.
Server responded with 0 code
- Wiki : attach a file not working (#52243) · Issues · GitLab.org / GitLab FOSS · GitLab
- NGINX settings | GitLab
- Mixed content - Web security | MDN
gitlab-wiki 에서 파일 업로드시 위와 같은 에러가 발생될 수 있다. 서버 로그나 네트워크 상태를 확인해 봤을 때 별다른 요청을 하지 않았다면 브라우저 콘솔을 확인해 보자. 다음과 같은 에러가 출력되었을 확률이 높다.
<span style="color: red">혼합된 액티브 콘텐츠 “http://git.your.com/api/v4/projects/51/wikis/attachments” 로드를 차단함
위의 경고는 MDN 사이트에서 자세한 확인할 수 있다. 잘 보면 https사이트에서 http로 호출하는 것을 확인할 수 있다.
설정 파일의 external_url
값에 http
를 https
로 변경하면 도니다.
단, traefik 같은 프록시로 외부 접근은 https, 내부를 http로 구성했다면 다음과 같이 설정하면 된다.
# external_url 'GENERATED_EXTERNAL_URL'
external_url 'https://your_externarl_url'
nginx['listen_port'] = 80
nginx['listen_https'] = false
nginx['proxy_set_headers'] = {
"X-Forwarded-Proto" => "https",
"X-Forwarded-Ssl" => "on"
}
참고로 나는 nginx['proxy_set_headers']
부분은 셋팅하지 않아도 잘 작동하더라.
설정 완료후 컨테이너를 재시작하거나 다음 명령을 사용하면 된다.
List of Issue Tracking System
- Issue Tracking System
- Mantis
- Bugzilla
- Blossom
- Request Tracker
- The Bug Genie
- WebIssues
- ChiliProject
- Jira
- TRAC
- Redmine
- GitLab
- Yona
- git-bug - git repo에 저장되는 버그 트래커
- Kitemaker - 원격팀을 위한 JIRA 대체제 협업도구
- Plane - JIRA/Linear 의 오픈소스 대체제
- Linear
See also
Favorite site
- gitlab web site
- Download GitLab Community Edition (CE)
- Ubuntu에 GitLabHQ 설치하기 2
- 김대리 Gitlab 5.1 설치하다 3
- RHEL/CentOS 6에 gitlab 설치
- CentOS 6.5에서 GitLab rpm 설치 하기
- CENTOS6에 GITLAB설치 | CENTOS6にGITLABインストール
- gitlab 데이타와 첨부 파일을 백업하는 방법
- Ubuntu에 GitLabHQ 설치하기