How to Abort Jenkins build if a Variable is not empty?

时间:2018-06-08 16:07:20

标签: jenkins jenkins-plugins gerrit gerrit-trigger

I want to abort my jenkins freestyle job, if the gerrit patchset has a topic applied to it, I am using the gerrit-trigger plugin for jenkins. The freestyle job is getting triggerd on each new patchset upload.

I noticed that if there is a topic applied to the incoming patchset the GERRIT_TOPIC variable from the gerrit plugin is NOT empty:

#!"C:\Program Files\Git\bin\bash" -xe

if [ -z "$GERRIT_TOPIC" ]
then
      echo "GERRIT_TOPIC is empty"
      echo $GERRIT_TOPIC
else
      echo "GERRIT_TOPIC is NOT empty"
      echo $GERRIT_TOPIC
fi
  • I don't want to continue the build, if GERRIT_TOPIC is NOT empty
  • I want to abort is abruptly, and don't want the gerrit-trigger plugin to write Verified-1 to gerrit patchset
  • It will be good if gerrit-trigger plugin goes and adds a comment 'Build aborted' to gerrit patchset - but I am not sure if this behaviour is available in gerrit plugin.

0 个答案:

没有答案