[BUILD] Randomization script refactoring

1) Refactored randomization logic to the top
2) Add logics to support window platforms
This is Jenkins specific issue and how we use it.  As I recall,  on parent job, there was a scenario BUILD_* exists but not set.

Things may have changed.  This is worth a revisit when next round of refactoring occur.