'How to use generic trigger in jenkins to retrigger a pull request

I have a question, how to use generic trigger in jenkis to retrigger a pull request.

if I give "Rebuild" in comment in a pull request, a pipeline should be triggerd.

genericVariables {
                        genericVariable {
                            key("action")
                            value("\$.action")
                            expressionType("JSONPath") //Optional, defaults to JSONPath
                            regexpFilter("") //Optional, defaults to empty string
                            defaultValue("") //Optional, defaults to empty string
                        }
                        genericVariable {
                            key("commit_sha")
                            value("\$.pull_request.head.sha")
                            expressionType("JSONPath") //Optional, defaults to JSONPath
                            regexpFilter("") //Optional, defaults to empty string
                            defaultValue("\$.pull_request.head.sha") //Optional, defaults to empty string
                        }
                        genericVariable {
                            key("pr_number")
                            value("\$.number")
                            expressionType("JSONPath") //Optional, defaults to JSONPath
                            regexpFilter("") //Optional, defaults to empty string
                            defaultValue("\$.number") //Optional, defaults to empty string
                        }
                        genericVariable {
                            key("pr_title")
                            value("\$.pull_request.title")
                            expressionType("JSONPath") //Optional, defaults to JSONPath
                            regexpFilter("") //Optional, defaults to empty string
                            defaultValue("") //Optional, defaults to empty string
                        }
                        genericVariable {
                            key("commits_url")
                            value("\$.pull_request.commits_url")
                            expressionType("JSONPath") //Optional, defaults to JSONPath
                            regexpFilter("") //Optional, defaults to empty string
                            defaultValue("\$.pull_request.commits_url") //Optional, defaults to empty string
                        }
                        genericVariable {
                            key("pr_labels")
                            value("\$.pull_request.labels")
                            expressionType("JSONPath") //Optional, defaults to JSONPath
                            regexpFilter("") //Optional, defaults to empty string
                            defaultValue("\$.pull_request.labels") //Optional, defaults to empty string
                        }
                        genericVariable {
                            key("head_branch_name")
                            value("\$.pull_request.head.ref")
                            expressionType("JSONPath") //Optional, defaults to JSONPath
                            regexpFilter("") //Optional, defaults to empty string
                            defaultValue("") //Optional, defaults to empty string
                        }
                        genericVariable {
                            key("changes_title_from")
                            value("\$.changes.title.from")
                            expressionType("JSONPath") //Optional, defaults to JSONPath
                            regexpFilter("") //Optional, defaults to empty string
                            defaultValue("") //Optional, defaults to empty string
                        }

                         genericVariable {
                            key("comment_body")
                            value("\$.comment.body")
                            expressionType("JSONPath") //Optional, defaults to JSONPath
                            regexpFilter("Rebuild") //Optional, defaults to empty string
                            defaultValue("") //Optional, defaults to empty string
                        }

                    }

I have tried this solution, if I leave Rebuild in comment, the pipeline will be triggerd, but it needs more information, such as pull reuqest number.

I tried to set defaultValue("")` just like this:

 defaultValue("\$.number") //Optional, defaults to empty string

but it did not work.

any solutions?
``


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source