Generally, yes Committed Use Discounts are designed to be flexible for exactly this kind of scenario.
Unlike some other providers' bulk discounts, GCP Commitments are purchased based on the amount of vCPU and RAM you expect to be using over a time period, regardless of the shape or number of instances you run. You can change machine shapes at any point in time with no penalties or conversions, or apply the discounts across a range of different machines you are running. So for example, if you buy 5 vCPU worth of commitment, the system will give a discount for 5 of the vCPU you are using at every point in time, and this is evaluated continuously as your fleet usage changes. Note, it is
per unit time meaning, you cannot "store up" the discount. If you ran 0 vCPUs for 1 hour and 10 vCPUs for the next hour, you would pay the monthly equivalent for 5 discounted vCPUs the first hour (even though you're running 0), and 5 discounted vCPUs the second hour, and the hourly/minutely/secondly requirement of the extra 5 vCPUs in that second hour. The extra 5 vCPUs in that hour would be eligible for consideration as sustained use discounts, however.
Finally, about sustained use discounts. What was said above might not be entirely correct regarding whether you would qualify for any SUD; we do some calculations to help you out in those use cases. Assume for example that you had no committments purchased and had an autoscaling use case. SUD calculates what our docs call "inferred instances." That means that if you run multiple instances that are the same size and shape, in the same zone, then we treat them as if they were one machine for the purpose of calculating the discount. So if your autoscaler ran extra instances at certain points in time, you would likely see some discount if the sum of those instances were running 25% or more of the month. We designed this "inferring" exactly for that type of scenario.
Now, when you have committed use discounts, then sustained use "inference" calculations are done a little differently. In that case we combine together the usage of VMs that are in the same "family" (e.g. all n1-standards, all n1-highmems, etc). This is more compatible with the way committed use discounts work, which could otherwise lead to lower discounts.
Paulo, in your scenario I believe it may make sense to find your lowest number of vCPUs running at any given time and buy a commitment for that many vCPUs and RAM. For the build machines, if you are running multiple machines for 30-50% of the hours of the day, I would expect you will see some SUD for that through inferred instances.