Search code examples
jenkinsjenkins-pluginsgitbucket

GenericWebhookTrigger not triggering specific build


I have Jenkins running normally and a pipeline with specifications below. I set the pipeline configuration to use the Generic Webhook Trigger with the same configuration as specificated in pipeline. The webhook is also configured in my gitbucket repository to only send push triggers. But when I test it, the response is 200 and a body response with "triggered":false.

Pipeline:

pipeline {
    agent any
    triggers {
    GenericTrigger(
     genericVariables: [
        [key: 'ref', value: '$.ref']
     ],
     genericHeaderVariables: [
        [key: 'X-GitHub-Event', regexpFilter: '']
     ],

     causeString: 'Triggered on $ref',

     token: '123456',

     printContributedVariables: true,
     printPostContent: true,

     silentResponse: false,

     regexpFilterText: '$ref',
     regexpFilterExpression: 'refs/heads/' + 'master'
    )
  }

    stages{...

Response body from gitbucket webhook:

{"status":"ok","data":{"triggerResults":{"testePipeline":{"id":0,"regexpFilterExpression":"refs/heads/master","regexpFilterText":"","resolvedVariables":{"ref":"","x_github_event":"","x_github_event_0":""},"triggered":false,"url":""}}}}

Solution

  • I had the same issue as above,

    {
      "jobs": {
        "Test": {
          "regexpFilterExpression": "(refs/heads/Dev|refs/heads/master)",
          "triggered": false,
          "resolvedVariables": {
            "ref": ""
          },
          "regexpFilterText": "",
          "id": 0,
          "url": ""
        }
      },
      "message": "Triggered jobs."
    }
    

    The reason was my content type was not application/json in Github. Corrected it and the build ran fine.