安裝與設定遇過的問題
- 如果遇到網頁無法開啟,或是顯示錯誤訊息,可以透過以下方式檢視 GitLab 的日誌.
root@ben-virtual-machine:~# gitlab-ctl tail
- EXTERNAL_URL 設定錯誤會讓網頁無法開啟,可以透過修改設定檔.
root@ben-virtual-machine:~# vi /etc/gitlab/gitlab.rb external_url "http://192.168.31.136"
執行前須注意 要把預設密碼儲存起來 ,密碼檔 /etc/gitlab/initial_root_password 將在 24 小時後第一次重新配置運行(gitlab-ctl reconfigure )時自動刪除.
並透過指令 Reconfigure GitLab .
root@ben-virtual-machine:~# gitlab-ctl reconfigure
Note:
這是可以指定埠 port ,讓 Gitlab 幫我們把 Nginx (Web Server) 預設的 80 port ,透過 Port Forwarding 轉成其他 port.root@ben-virtual-machine:~# vi /etc/gitlab/gitlab.rb external_url "http://192.168.31.136:8080"
網頁連線就須使用 成http://192.168.31.136:8080
- 預設的專案 Project 或是 Repository 權限為 Private (需帳號密碼才能存取)
可以在網頁修改為 Public 或是使用以下方式來儲存使用者帳號與密碼.網頁變更 project visibility
- Settings > General
- Expand Visibility, project features, permissions.
- Change Project visibility to either Private, Internal, or Public and Save changes.
或是變更預設 project visibility
- Select Settings > General.
- Expand the Visibility and access controls section.
- Select the desired default project visibility:
- Select Save changes.
儲存使用者帳號與密碼.
root@ben-virtual-machine:~# vi ~/.netrc machine 192.168.31.136 login ben password 111111
並修改權限.
root@ben-virtual-machine:~# chmod 600 ~/.netrc
- 存放密碼的檔案 /etc/gitlab/initial_root_password 會在 24 小時後第一次重新配置運行(gitlab-ctl reconfigure )時自動刪除,訊息如下.
Found old initial root password file at /etc/gitlab/initial_root_password and deleted it.
密碼檔已被刪除.
root@ben-virtual-machine:~# cat /etc/gitlab/initial_root_password cat: /etc/gitlab/initial_root_password: No such file or directory
可以過以下指令重新設定密碼 (至少 8碼 + 數字與英文)
root@ben-virtual-machine:~# gitlab-rake 'gitlab:password:reset[root]' Enter password: Confirm password: Unable to change password of the user with username root. Password is too short (minimum is 8 characters)
root@ben-virtual-machine:~# gitlab-rake 'gitlab:password:reset[root]' Enter password: Confirm password: Unable to change password of the user with username root. Password must not contain commonly used combinations of words and letters
root@ben-virtual-machine:~# gitlab-rake 'gitlab:password:reset[root]' Enter password: Confirm password: Password successfully updated for user with username root.
CI 遇到的問題
- CentOS 8 執行 git clone 會有以下的錯誤訊息
[root@localhost ~]# git clone http://192.168.31.138/ben/runner_test.git Cloning into 'runner_test'... (gnome-ssh-askpass:40100): Gtk-WARNING **: 01:58:56.040: cannot open display: error: unable to read askpass response from '/usr/libexec/openssh/gnome-ssh-askpass' Username for 'http://192.168.31.138': ^C
須執行以下指令
[root@localhost ~]# unset SSH_ASKPASS
[root@localhost ~]# git clone http://192.168.31.138/ben/runner_test.git Cloning into 'runner_test'... Username for 'http://192.168.31.138': ben Password for 'http://ben@192.168.31.138': remote: Enumerating objects: 4, done. remote: Counting objects: 100% (4/4), done. remote: Compressing objects: 100% (3/3), done. remote: Total 4 (delta 0), reused 0 (delta 0), pack-reused 0 Receiving objects: 100% (4/4), done.
- 執行 Job 時出現的錯誤.
Using SSH executor... ERROR: Preparation failed: ssh command Connect() error: getting host key callback: open /root/.ssh/known_hosts: no such file or directory
需先登入 SSH Server (讓 GitLab 這邊端先產生 Key 檔案 )
root@ben-virtual-machine:~# ssh root@192.168.31.128 The authenticity of host '192.168.31.128 (192.168.31.128)' can't be established. ED25519 key fingerprint is SHA256:gVQMC2PcfkTPQruPWXi+2MVa3WbsfCPOti7NuCNSsSw. This key is not known by any other names Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added '192.168.31.128' (ED25519) to the list of known hosts. root@192.168.31.128's password: Activate the web console with: systemctl enable --now cockpit.socket Last login: Mon Jul 17 22:52:24 2023 from 192.168.31.1 [root@localhost ~]# exit logout Connection to 192.168.31.128 closed.
- git 無法下載
remote: You are not allowed to download code from this project. fatal: unable to access 'http://192.168.31.140/ben/runner_test.git/': The requested URL returned error: 403 ERROR: Job failed: Process exited with status 1
預設的專案 Project 或是 Repository 權限為 Private (需帳號密碼才能存取)
可以在網頁修改為 Public 或是使用以下方式來儲存使用者帳號與密碼.網頁變更 project visibility
- Settings > General
- Expand Visibility, project features, permissions.
- Change Project visibility to either Private, Internal, or Public and Save changes.
或是變更預設 project visibility
- Select Settings > General.
- Expand the Visibility and access controls section.
- Select the desired default project visibility:
- Select Save changes.
- 如有修改過 runner 設定檔案 /etc/gitlab-runner/config.toml , 需要重啟 gitlab-runner 服務.
root@ben-virtual-machine:~# systemctl restart gitlab-runner
- Windows 端無安裝 python
請參考 Windows 安裝 Python – https://benjr.tw/106175Running with gitlab-runner 16.6.1 (f5da3c5a) on VM win10 XhxhUwtwA, system ID: s_6ce8c193f63e Preparing the "shell" executor 00:00 Using Shell (powershell) executor... Preparing environment 00:01 Running on DESKTOP-THOBKJO... Getting source from Git repository 00:06 Fetching changes with git depth set to 20... Initialized empty Git repository in C:/GitLab-Runner/builds/XhxhUwtwA/0/root/powershell_test/.git/ Created fresh repository. Checking out fa456d12 as detached HEAD (ref is main)... git-lfs/3.4.0 (GitHub; windows amd64; go 1.20.6; git d06d6e9e) Skipping Git submodules setup Executing "step_script" stage of the job script 00:01 $ python3 hello.py Ben Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases. ERROR: Job failed: exit status 9009
- 預設 shell 會使用 “pwsh”
需到 C:\GitLab-Runner\config.toml 檔案 修改成 shell = “powershell” .Running with gitlab-runner 16.6.1 (f5da3c5a) on VM win10 XhxhUwtwA, system ID: s_6ce8c193f63e Preparing the "shell" executor Using Shell (pwsh) executor... Preparing environment ERROR: Job failed (system failure): prepare environment: failed to start process: exec: "pwsh": executable file not found in %PATH%. Check https://docs.gitlab.com/runner/shells/index.html#shell-profile-loading for more information
- Windows python 路徑問題
請參考 Windows 安裝 Python – https://benjr.tw/106175Running with gitlab-runner 16.6.1 (f5da3c5a) on VM win10 XhxhUwtwA, system ID: s_6ce8c193f63e Preparing the "shell" executor 00:00 Using Shell (powershell) executor... Preparing environment 00:00 Running on DESKTOP-THOBKJO... Getting source from Git repository 00:03 Fetching changes with git depth set to 20... Reinitialized existing Git repository in C:/GitLab-Runner/builds/XhxhUwtwA/0/root/powershell_test/.git/ Checking out c393deb3 as detached HEAD (ref is main)... git-lfs/3.4.0 (GitHub; windows amd64; go 1.20.6; git d06d6e9e) Skipping Git submodules setup Executing "step_script" stage of the job script 00:01 $ py hello.py Ben py : �L�k���� 'py' ���J�O�_�� Cmdlet�B���ơB���O�ɩΥi�����{�����W�١C���ˬd�W�٫��r�O�_���T�A�p�G�]�t���|���ܡA�нT�{ ���|�O�_���T�A�M���A�դ@���C ���� �u��:254 �r��:1 + py hello.py Ben + ~~ + CategoryInfo : ObjectNotFound: (py:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException ERROR: Job failed: exit status 1
- PowerShell 執行權限
需使用 administrator 的權限去執行.PS C:\GitLab-Runner> .\gitlab-runner.exe install Runtime platform arch=amd64 os=windows pid=2580 revision=f5da3c5a version=16.6.1 FATAL: Failed to install gitlab-runner: Access is denied.
Git 遇過的問題
- 需先回到 建立 SSH 連線所需公私鑰 步驟.
git@192.168.31.139: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
- 中文版的 VSCode 無法同意第一次要接收對方的公鑰,需改成英文版.
第一次要下載 Gitlab 的 Project 須接受對方的公鑰卻一直卡在這邊, 我猜應該是 SSH 連線時須回答 “yes” 而不是 “是” 所造成的影響.
- 需先回到 安裝 git 套件步驟.
- 需先回到 git config 做初始化
- 上傳時需寫 Commit
Gitea 遇過的問題
從 Gitlab 連線到 Gitea 抓取 repository 時出現以下的錯誤訊息.
無法使用指定的URL:「Requests to the local network are not allowed
這是因為沒設定 Outbound requests(出站請求) , 請參考 https://benjr.tw/106010 步驟來設定.
沒有解決問題,試試搜尋本站其他內容