Folder support

When using an `ItemGroup` such as from the CloudBees Folders plugin, the build pipeline misbehaves in a few ways. Trying to correct the problems I can find, though other bugs are reproducible even at root level that make it impossible to be sure everything is fixed.