I am using generic-webhook-trigger in Jenkins to trigger job when events happen in Github.
It seems I have to extract each variable I need from the big JSON request body to convert them to env-var.
Is it possible to pass the whole JSON body to the Jenkins job and have it parse it?
You can achieve what you want by assigning the entire body to a specific variable, then read it as Json in your code and parse it by yourself.
For example, if your payload (received post content) is:
You can define a single parameter in your generic webhook configuration called
payload, set the expression for that parameter to$, set the expressionTypeJSONPath, and when the job is triggered that parameter will include the entire content of the received post content.You can then parse it by yourself:
You can see more advanced examples for using the
generic-webhook-triggerconfigurations plugin Here, and especially This one which is more relevant for your requirements.