You will need an external script.
Pull out the project (git clone / fetch) and then before continuing with the build check to see if a particular message is in your repository.
To check if your message is there, you can use the git show or git log commands.
git log
git log --all --grep='<your message>'
git grep
git grep '<your message>' $(git rev-list --all)
Outside jenkins
Add code to the git hook , which checks that you want to find * messages, comment, etc.), and only if he finds it, will Jenkins call through the REST API and begin your work.
This is how I use Jenkins, I check something that I am looking for, and then im calls Jenkins via API
More here and here
source share