Reputation: 73
I have a multibranch pipeline and I am using pipeline-github plugin to trigger by comments on PR and it's fine.
Now I would like to trigger only by PR comments.
But there is a limitation
The Pull Request's job/build must have run at least once for the trigger to be registered. If an initial run never takes place then the trigger won't be registered and cannot pickup on any comments made.
In my configuration, PR are discovered and not triggered by the basic-branch-build-strategies plugin so config.xml is created in the job/PR directory.
So I think I am missing only to register the trigger. How can I do programmatically? Is there a way to force a "fake" first run? What is the steps that I miss?
Thanks in advance, Pierluigi
Upvotes: 0
Views: 182
Reputation: 73
solved with your suggestion adding:
def buildCause = currentBuild.getBuildCauses()[0]
echo "Build caused by: ${buildCause}\n"
if ("${buildCause}".contains("github.trigger.IssueCommentCause")) {
echo "Build will proceed..."
} else {
currentBuild.result = 'ABORTED'
error('Skipping build…')
}
maybe it can be improved but it's fine
Upvotes: 1