手动从配置项中删除项目 [英] Remove artifacts from CI manually

查看:14
本文介绍了手动从配置项中删除项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在gitlab.com上有一个使用配置项功能的私有存储库。某些配置项作业创建存储的工件文件。我刚刚通过将以下内容添加到CI配置实现了一天后自动删除工件:

expire_in: 1 day

这很有效-但是,旧的工件不会被删除(正如预期的那样)。所以我的问题是:

如何删除旧工件或未过期的工件?(在gitlab.com上,无法直接访问服务器)

推荐答案

如果您没有直接访问服务器的权限,可以使用GitLab REST 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 "
"
done

这篇关于手动从配置项中删除项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆