I have a web hook configured in my GitHub org that triggers a Jenkins pipeline every time a new repo is created. What I am trying to do is get some of the values from the payload which triggers the job and use them in a script within the pipeline. One such example would be the repo name, for instance the payload looks something like this:
{
"action": "created",
"repository": {
"name": "my-new-repo"
[...]
}
[...]
}
I tried assigning the repository["name"] value to a variable in the Jenkinsfile but that did not seem to work:
pipeline{
environment {
REPO_NAME = $.repository.name
}
[...]
}
Also tried it with quotes and some other ways in formatting but still could not get it to be assigned to the REPO_NAME variable.
Here is an example of how to Read different attributes from the Webhook request.