Skip to content

Commit

Permalink
[KOGITO-1884] - Clean up old cucumber test namespaces (apache#10)
Browse files Browse the repository at this point in the history
See: https://issues.redhat.com/browse/KOGITO-1884

Signed-off-by: Mauricio Magnani <mmagnani@redhat.com>
  • Loading branch information
msmagnanijr authored Jun 4, 2020
1 parent 95e19c6 commit 4768d8f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
13 changes: 13 additions & 0 deletions clean-old-namespaces-Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
pipeline{
agent {label 'operator-slave'}
triggers {
cron('@midnight')
}
stages{
stage('Clean Old Namespaces'){
steps{
sh "tools/clean-old-namespaces.sh"
}
}
}
}
14 changes: 14 additions & 0 deletions tools/clean-old-namespaces.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

IN=$(kubectl get namespace -o jsonpath='{range .items[*].metadata}{.name}{";"}{.creationTimestamp}{"\n"}{end}' | awk '/cucumber-/')
projects=$(echo $IN | tr "\n" "\n")
date_cleanup=$(date -u +"%Y-%m-%dT%H:%M:%SZ" -d "1 day ago")
for values in $projects
do
name_project=${values%;*}
date_project=${values#*;}
if [[ "$date_project" < "$date_cleanup" ]] ; then
oc delete project $name_project
echo "delete project ${name_project}"
fi
done

0 comments on commit 4768d8f

Please sign in to comment.