Hello,
I work in a software development environment and trying to automate the task of deleting old builds and retaining the latest ones using 'minimum builds to keep' and 'maximum days to keep' as parameters. There are folders for 'Daily', 'CI', 'RC', and 'Archived' builds folders. The problem I am facing is that in the CI folder there are multiple branches, e.g.
"ABC 2014-PS CI_20141209.3",
"ABC 2014-PS CI_20141209.4",
"ABC 2014-PS CI_20141209.5",
"ABC DEF CI_20141210.13",
"ABC DEF CI_20141210.14",
"ABC DEF CI_20141210.15",
"ABC DEF CI_20150102.1",
"ABC DEF CI_20150102.2",
"ABC DEF CI_20150102.3",
"ABC DEF-2015 CI_20150107.2",
"ABC DEF-2015 CI_20150107.3",
"ABC DEF-2015 CI_20150107.4"
I am using a ToString().SubString() .IndexOf().Trim() combination to get the unique branch set but not getting the right list. Here's the string I am using
$currentBranch
=$branch.ToString().Substring(0, $branch.ToString().IndexOf("CI_")-1).Trim()
The correct list of "unique" branches should be:
"ABC 2014-PS"
"ABC DEF"
"ABC DEF-2015"
What am I not doing correctly in the string above? Thank you in advance.