Developing custom label support on Gerrit trigger plugin

80 views
Skip to first unread message

George Cimpoies

unread,
Sep 4, 2018, 8:32:54 AM9/4/18
to jenkin...@googlegroups.com, nicolas de loof, Robert Sandell
Hi!

I've began to work on adding custom label support on Gerrit Trigger plugin.
Currently, there are 2 default labels:Code-Review and Verified, which have hardcoded votes on the 5 distinct build outcomes (successful, failed, started, unstable and not built)

Those votes on each label are persisted with the help of a databound setter, like so:

<tr><td></td><td><div style="font-weight: bold; border-bottom: 1px solid black; margin-bottom: 0.2em; margin-top: 0.4em;">${%Verify}</div></td></tr>
<f:entry title="${%Started}"
field="gerritBuildStartedVerifiedValue"
help="/plugin/gerrit-trigger/trigger/help-GerritBuildStartedVerified.html">
<f:textbox name="gerritBuildStartedVerifiedValue"
value="${it.gerritBuildStartedVerifiedValue}"
default=""
checkUrl="'descriptorByName/com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.GerritTrigger/emptyOrIntegerCheck?value='+escape(this.value)"/>
</f:entry>
@DataBoundSetter
public void setGerritBuildStartedVerifiedValue(Integer gerritBuildStartedVerifiedValue) {
this.gerritBuildStartedVerifiedValue = gerritBuildStartedVerifiedValue;
}
So it's a 1-to-1 relationship between the java field and the actual textbox in the web UI section.
The persistance is done by reflection, so the gerritBuildStartedVerifiedValue is matched by setGerritBuildVerifiedStartedValue automatically.

Now my question:
How do I persist a custom list of labels? Since I don't know how many labels there are at some point (and what their names will be) I can't work with databound setters.

<j:forEach items="${instance.getVerdictCategoriesList()}" var="p">
<tr>
<td></td>
<td>
<div style="font-weight: bold; border-bottom: 1px solid black; margin-bottom: 0.2em; margin-top: 0.4em;">
${p.verdictValue}
</div>
</td>
</tr>
<f:entry title="${%Started}"
field="startedVote">
<f:textbox name="startedVote"
value=""
default=""/>
</f:entry>

<f:entry title="${%Successful}"
field="successfulVote">
<f:textbox name="successfulVote"
value=""
default=""/>
</f:entry>

<f:entry title="${%Failed}"
field="failedVote">
<f:textbox name="failedVote"
value=""
default=""/>
</f:entry>

<f:entry title="${%Unstable}"
field="unstableVote">
<f:textbox name="unstableVote"
value=""
default=""/>
</f:entry>

<f:entry title="${%Not Built}"
field="notBuiltVote">
<f:textbox name="notBuiltVote"
value=""
default=""/>
</f:entry>
</j:if>
</j:forEach>
This is what I currently have in order to display custom labels and their custom votes, but I don't see how I can persist the custom votes values. On the UI, it looks like this (currently added only 1 custom label called Validated) :
image.png

I already have a data structure containing all the custom labels and their custom votes on each build outcome available through instance.getVerdictCategoriesList() but I don't know how I can set those values from the UI.
Any help is much appreciated!

P.S. Keep in mind that there can be an indefinite number of custom labels that you can add.
--
George Cimpoies
R&D • Itiviti
Software Engineer

Mobile: +40 751 048 489
george....@ullink.com

1 Victor Deleu Street | Cluj-Napoca, Cluj 400112



The information contained in or attached to this email is strictly confidential. If you are not the intended recipient, please notify us immediately by telephone and return the message to us.


Email communications by definition contain personal information. The ITIVITI group of companies (of which ULLINK forms part) is subject to European data protection regulations. ULLINK’s Privacy Policy is available at www.ullink.com. ULLINK expects the recipient of this email to be compliant with ULLINK’s Privacy Policy and applicable regulations. Please advise us immediately at datapro...@ullink.com if you are not compliant with these.

Reply all
Reply to author
Forward
0 new messages