jenkinsci / generic-webhook-trigger-plugin

Can receive any HTTP request, extract any values from JSON or XML and trigger a job with those values available as variables. Works with GitHub, GitLab, Bitbucket, Jira and many more.
https://plugins.jenkins.io/generic-webhook-trigger
404 stars 159 forks source link

Triggering is not working with Token Credential ID #206

Closed raksit31667 closed 3 years ago

raksit31667 commented 3 years ago

Version report

Jenkins on Docker v2.222 Generic Webhook Plugin v1.72

Reproduction steps

Screen Shot 2564-06-02 at 10 12 07

POST https://<jenkins-url>/generic-webhook-trigger/invoke?token=<token-here>

Results

Expected result:

It should return HTTP 200 OK with new job running.

Actual result:

It returns HTTP 404 NOT FOUND without any jobs running.

Additional info

It works if I hardcode token input instead of using tokenCredentialId.

tomasbjerre commented 3 years ago

I tried with Jenkins 2.277.4.

Created a secret text credential with id theid.

Pipeline:

 properties([
  pipelineTriggers([
   [$class: 'GenericTrigger',
    genericVariables: [
     [
      key: 'href',
      value: '$.href'
     ]
    ],

    causeString: 'Triggered on $ref',

    tokenCredentialId: 'theid',

    printContributedVariables: true,
    printPostContent: true,

    silentResponse: false
   ]
  ])
 ])

Trigger with Curl:

curl -vs http://localhost:8080/jenkins/generic-webhook-trigger/invoke?token=abc123 2>&1

Works for me.

Note that you have to run a pipeline once, to apply the properties to the job. So you can verify what has been applied by inspecting the job. In my case I can see:

image

raksit31667 commented 3 years ago

Hi @tomasbjerre, thank you for your support.

You are right, I missed the part where I needed to run a pipeline once as documented here.