If you use gerrit-trigger you don't need to discover new branches. You get the GERRIT_BRANCH from the trigger data.
checkout ([poll: false,
scm: [$class: 'GitSCM',
branches: [[name: '$GERRIT_BRANCH']],
doGenerateSubmoduleConfigurations: false,
extensions: [[$class: 'BuildChooserSetting',
buildChooser: [$class: 'GerritTriggerBuildChooser']],
],
gitTool: 'Default',
submoduleCfg: [],
userRemoteConfigs: [[credentialsId: 'XXXX',
refspec: '$GERRIT_REFSPEC',
url: 'ssh://<host here>/$GERRIT_PROJECT']]
]
])