userid-validation: erase score after trigger
The newer versions of Gerrit seem to send events that include the
"Ok-To-Test=1" score on future comments by Jenkins itself. This can
cause Jenkins to infinite loop itself by seeing its own "Validated=1"
comment _with_ an "Ok-To-Test=1" inside it. There isn't much capability
to filter this out in the Jenkins Gerrit Trigger Plugin. Attempt to
work around it by adding immediately erasing the Jenkins Ok-To-Test
score.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I93525b4d8ba7321a5669da4e0296a62cc342fb76
diff --git a/jenkins/userid-validation b/jenkins/userid-validation
index 3a89953..fc882ee 100755
--- a/jenkins/userid-validation
+++ b/jenkins/userid-validation
@@ -95,6 +95,12 @@
"${GERRIT_CHANGE_NUMBER},${GERRIT_PATCHSET_NUMBER}" \
--label=Ok-To-Test=1 -t autogenerated:jenkins \
"--message='User approved, CI ok to start'"
+
+ # Immediately erase the score to prevent infinite triggers.
+ "${GERRIT_SSH_CMD[@]}" review \
+ "${GERRIT_CHANGE_NUMBER},${GERRIT_PATCHSET_NUMBER}" \
+ --label=Ok-To-Test=0 -t autogenerated:jenkins
+
exit 0
fi