I want to fail-fast on Gerrit triggered Jenkins jobs when the changes are outdated and they need rebasing by adding a piece of code at the start of the job that triggers and error: "Rebase your change first."
You can find the list of Jenkins variables defined by Gerrit plugin at What environment variables are passed go Jenkins when using the Gerrit Trigger Plugin?
This broken attempt:
Somehow this worked on some jobs using pipelines but failed on others, I suspect due to a different checkout method. So, still looking for a reliable way of doing it.