How to execute a revert from the pipeline?

Hello …

I have a pipeline that execute right after a merge to the master branch, that clone the master branch of the repo in the server, and restart the service, and i have a test stage so in case of fail the tests, i want to execute the revert to the previous state in the repo, to clone and restart the service with the previous values.
Please,… give me a hint…

How can i call the revert or other way to do that…

Thank you in advance…