I'm assuming the numbers are removed because on some systems, environment variables cannot start with a number. However, the implementation creates difficult to workaround aliasing problems where job names like my_build_win32 and my_build_win64 resolve to same variable (my_build_win_).
A better implementation that only removes numbers from the start of the variable would be:
projectName.toUpperCase().replaceAll("^[^A-Z]+", "_").replaceAll("[^A-Z0-9]+", "_")
This prevents invalid variables and should avoid aliasing for 99.5% of job names.