I wasn’t really satisfied with the accepted approach, so I simplified it a little.
Basically set a default property in the normal properties block, and only override when appropriate (instead of an effective switch statement):
<properties>
<!-- Sane default -->
<buildNumber>0</buildNumber>
<!-- the other props you use -->
</properties>
<profiles>
<profile>
<id>ci</id>
<activation>
<property>
<name>env.buildNumber</name>
</property>
</activation>
<properties>
<!-- Override only if necessary -->
<buildNumber>${env.buildNumber}</buildNumber>
</properties>
</profile>
</profiles>