2017-02-28 78 views
6

我在gitlab.com上有一個使用CI功能的私有資源庫。一些CI作業創建存儲的工件文件。我只是實現了由文物自動後一天加入該到CI配置中刪除:從CI中手動刪除工件

expire_in: 1 day 

這偉大工程 - 然而,舊的文物不會被刪除(如預期)。所以我的問題是:

如何刪除舊的工件或不會過期的工件? (上gitlab.com,沒有直接訪問服務器)

回答

4

我沒有GItlab 8.17,並且能夠通過導航到存儲在目錄服務器本身以刪除特定作業文物,默認路徑是:

/var/opt/gitlab/gitlab-rails/shared/artifacts/<year_month>/<project_id?>/<jobid> 

拆卸作業或者乾脆內容都整個文件夾,從消失GitLab pipline頁工件視圖

存儲路徑可在文檔描述的改變: https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/administration/job_artifacts.md#storing-job-artifacts

+0

不幸的是,我有服務器不能直接訪問作爲倉庫在gitlab.com主持。我更新了我的問題,更詳細地指出了這一點。 – user1251007

+0

根據GitLab的說法,如果您有權訪問GitLab服務器,您需要通過gitlab-rails控制檯進行刪除。否則,在管理用戶界面中查看項目大小時可能會看到差異,因爲基礎數據庫未更新。參考:https://gitlab.com/gitlab-org/gitlab-ce/issues/5572#note_3359570 –

0

可以使用GitLab REST API如果您沒有直接訪問服務器的權限,則從作業中刪除工件。下面是一個使用該API一個sample curl script

#!/bin/bash 

# project_id, find it here: https://gitlab.com/[organization name]/[repository name]/edit inside the "General project settings" tab 
project_id="3034900" 

# token, find it here: https://gitlab.com/profile/personal_access_tokens 
token="Lifg_azxDyRp8eyNFRfg" 
server="gitlab.com" 

# go to https://gitlab.com/[organization name]/[repository name]/-/jobs 
# then open JavaScript console 
# copy/paste => copy(_.uniq($('.ci-status').map((x, e) => /([0-9]+)/.exec(e.href)).toArray()).join(' ')) 
# press enter, and then copy the result here : 
# repeat for every page you want 
job_ids=(48875658 48874137 48873496 48872419) 

for job_id in ${job_ids[@]}; 
do 
URL="https://$server/api/v4/projects/$project_id/jobs/$job_id/erase" 
echo "$URL" 
curl --request POST --header "PRIVATE-TOKEN:${token}" "$URL" 
echo "\n" 
done 
+0

謝謝你的回答。但是,請在答案中提供所有必要的詳細信息,並保留鏈接供參考。就目前所寫,這不僅僅是一個答案而是一個評論。使用Rest API看起來很有希望! – user1251007