Git/Jenkins權限問題

Git/Jenkins權限問題

作業系統:Ubuntu伺服器10.04 LTS

我在權限方面遇到了一個奇怪的問題,並且似乎無法找出導致該問題的原因。

設定如下:

Git 儲存庫資料夾(以及其中的檔案)由 root 擁有,我們用於專案的群組具有 rws 權限,例如:

   ll /path/to/project
   drwxrwsr-x 7 root project                4096 2013-03-14 19:19 project

我們的 jenkins 使用者是我們為專案建立的所有群組的成員,包括範例中的群組。 jenkins 應用程式由 jenkins 使用者啟動,以確保它具有對專案資料夾的完全存取權。

如果我刪除這些 git 資料夾上「其他」的讀取和執行權限,我們的建置就會失敗,並指出:

 fatal: '/path/to/project' does not appear to be a git repository

ps:沒有 SELinux 運行

答案1

我猜這是您對存儲庫中子目錄的權限。

# Set the same ownerships for every file and directory within the repository
sudo chown -R root:project /path/to/project

# Remove permissions for others on all files
sudo chmod o-rwx $(find /path/to/project -not -type d)

如果您希望群組成員寫回更改:

# Set permissions for all subdirectories
sudo chmod 2770 $(find /path/to/project -type d)

如果您希望群組成員具有唯讀存取權限:

# Remove write permissions for group members for every file
sudo chmod g-w $(find /path/to/project -not -type d)

# Set permissions for all subdirectories
sudo chmod 2750 $(find /path/to/project -type d)

現在,只要 jenkins 使用者是專案群組的成員,他就應該能夠毫無問題地複製 git 儲存庫。

然而,如果您的系統啟用了 SELinux,事情可能會變得有點棘手。

快樂編碼:)

相關內容