Skip to main content
Version: QB80

Build Against Specific Gerrit Change

Situation

Sometimes it is desirable to run build against specific Gerrit change.

Resolution (since 6.0.25)

  1. Define a variable say "change", with prompt setting set to prompt as selection box , with below choice:

    ${groovy: 
    // assume your Gerrit repository defined at QuickBuild side is named "gerrit"
    def repo = repositories.get("gerrit");

    def choices = "";
    for (each in repo.getOpenChanges()) {
    choices += each.customData.changeNo + ": " + each.customData.subject + ",";
    \}
    return choices;
    }

    This setting will prompt user with a list of Gerrit open changes for selection.

  1. Set up Gerrit repository at QuickBuild side and configure field change numbers as below:

    ${groovy:
    import com.pmease.quickbuild.util.StringUtils;

    def change = vars.getValue("change");
    if (change != null)
    return StringUtils.substringBefore(change, ":");
    else
    return "";
    }

    This tells QB to build against selected change in above step.

  2. Make sure option "Queue Changed Branches Only" in advanced configuration setting is set to no, as otherwise, QB will not run build even if change number is specified if a build has already been fired for a change.