Nice idea, could try that - but that would all happen after runScript already ran and the Trigger could have “triggered” already, right?
But I may have another idea, looking at ScmTrigger
it asks SCMDecisionHandler
for a decision on polling for changes - so in theory, I could just write a handler which does:
@Override
public boolean shouldPoll(@NonNull Item item) {
return false;
}
And it should never poll anything and trigger a build from that - I need to find time to setup [0], build an extension just for my testcase with that Handler and it should work - untested yet though.
Update: Did test it, works like expected.
[0] GitHub - jenkinsci/gradle-jpi-plugin: Build Jenkins Plugins with Gradle