api/new_code_periods/set allows you to set/configure the new code period via code.
We use both Powershell (manual) and Groovy (Jenkins) to implement this api
We have separate Jenkins jobs that people can use to set their new code period
People can run this on-demand. Timing of setting the new code period generally requires thought and is best accomplished by a developer or tech lead at the appropriate time in the applicaiion life cycle.