Created
July 4, 2017 09:48
-
-
Save Sam-Martin/f3aebae8a1ed625a92b309ac0e828a06 to your computer and use it in GitHub Desktop.
Clean up Jenkins Build history
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$BuildDirs = gci "W:\Jenkins\jobs\" -recurse -filter builds | ?{$_.psiscontainer} | |
$BuildDirs | %{ | |
$Builds = $_ | gci | select *,@{L="NameInt";e={[int]$_.name}} | ?{$_.nameint}| sort nameint -Descending | |
if($builds.Length -gt 30){ | |
$Builds[30..$($builds.length-1)].fullname | Remove-Item -Force -Recurse -verbose | |
}else{ | |
$Builds.Length | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment