def prepareBuildsForMode()

in vars/gerritPipeline.groovy [168:201]


def prepareBuildsForMode(buildName, mode="reviewdb", retryTimes = 1) {
    return {
        stage("${buildName}/${mode}") {
            def agentBuild = null
            for (int i = 1; i <= retryTimes; i++) {
                postCheck(new GerritCheck(
                    (buildName == "Gerrit-codestyle") ? "codestyle" : mode,
                    new Build(currentBuild.getAbsoluteUrl(), null)))
                try {
                    agentBuild = build job: "${buildName}", parameters: [
                        string(name: 'REFSPEC', value: "refs/changes/${env.BRANCH_NAME}"),
                        string(name: 'BRANCH', value: env.GERRIT_PATCHSET_REVISION),
                        string(name: 'CHANGE_URL', value: "${Globals.gerritUrl}c/${env.GERRIT_PROJECT}/+/${env.GERRIT_CHANGE_NUMBER}"),
                        string(name: 'MODE', value: mode),
                        string(name: 'TARGET_BRANCH', value: env.GERRIT_BRANCH)
                    ], propagate: false
                } finally {
                    if (buildName == "Gerrit-codestyle"){
                        Builds.codeStyle = new Build(
                            agentBuild.getAbsoluteUrl(), agentBuild.getResult())
                        postCheck(new GerritCheck("codestyle", Builds.codeStyle))
                    } else {
                        Builds.verification[mode] = new Build(
                            agentBuild.getAbsoluteUrl(), agentBuild.getResult())
                        postCheck(new GerritCheck(mode, Builds.verification[mode]))
                    }
                    if (agentBuild.getResult() == "SUCCESS") {
                        break
                    }
                }
            }
        }
    }
}