1.Harbor api版本
![](https://img-blog.csdnimg.cn/direct/3d492d4d830046bdb41dd44177646e41.png)
2.删除镜像方法
![](https://img-blog.csdnimg.cn/direct/e0c8cc50ad8f4eeabfd3cc5643a68f80.png)
3.查看reference方法
curl -u admin:Harbor12345 -X GET "https://xxxxx/api/v2.0/projects/项目名字/repositories/镜像名字/artifacts?page=1&page_size=1&with_tag=true&with_label=false&with_scan_overview=false&with_signature=false&with_immutable_status=false" | sed 's/,/\n/g' | grep digest | awk -F '"' '{print $4}'
4.执行删除命令
curl -u "admin:Harbor12345" -X DELETE "https://xxxxx/api/v2.0/projects/项目名字/repositories/镜像名字/artifacts/sha256:4d8a95c65a0646f329c8749ef4ffd58839a60be042feeb3ba9200dce28a1b7d7"
5.获取上传的第一个镜像的tag
curl -L -u admin:Harbor12345 -sS --max-time 30 --connect-timeout 60 --retry 300 --retry-delay 100 "xxxxx/api/v2.0/projects/项目名字/repositories/镜像名字/artifacts?page=1&page_size=1&with_tag=true&with_label=false&with_scan_overview=false&with_signature=false&with_immutable_status=false" -H "Expect:" | sed \'s/,/\\n/g\' | grep "none" | awk -F \':\' \'{print $2}\' | sed \'s/"//g\'`