The groovy script executed by Groovy Postbuild does not run on Matrix parent if this Post build publisher comes from a template project.
I order for the script to run on my several hundred jobs I would have to duplicate this script under each job. Maintenance would be a nightmare.
Thankfully Execute System Groovy script could load the script from a file, thus I solve my script duplication problem. It exposes some of the same variables as Groovy Postbuild, such as the current build. However I cannot get the script to run only on Matrix parent
Build -> Execute System Groovy script -> Script command
import hudson.matrix.MatrixBuild;
import hudson.matrix.MatrixRun;
if (build instanceof MatrixRun) {
println "MatrixRun child"
} else if (build instanceof MatrixBuild) {
println "MatrixBuild parent"
}
It seems it only runs on each matrix build configurations (childs).