Clean all airship artifacts too
[releng.git] / utils / retention_script.sh
1 #!/bin/bash
2 # SPDX-license-identifier: Apache-2.0
3 ##############################################################################
4 # Copyright (c) 2016 The Linux Foundation and others
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #  http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 ##############################################################################
17
18 for x in airship apex armband compass4nfv fuel ovsnfv
19 do
20
21   echo "Looking at artifacts for project $x"
22   echo "In path gs://artifacts.opnfv.org/$x"
23
24   while IFS= read -r artifact; do
25
26     artifact_date="$(gsutil ls -L $artifact | grep "Creation time:" | awk '{print $4,$5,$6}')"
27     age=$(($(date +%s)-$(date -d"$artifact_date" +%s)))
28     daysold=$(($age/86400))
29
30     if [[ "$daysold" -gt "10" ]]; then
31       echo "$daysold Days old deleting: $(basename $artifact)"
32       gsutil rm "$artifact"
33     else
34       echo "$daysold Days old retaining: $(basename $artifact)"
35     fi
36
37   done < <(gsutil ls gs://artifacts.opnfv.org/"$x" |grep -v "/$")
38 done