Skip to content

Commit

Permalink
Merge pull request #503 from JGranha/JENKINS-72649
Browse files Browse the repository at this point in the history
[JENKINS-72649] Add project parameter to SSH commands
  • Loading branch information
rsandell authored Mar 8, 2024
2 parents 6fe554e + e3a84e1 commit 20643d8
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -334,27 +334,33 @@ public void setValues(JSONObject formData) {

gerritVerifiedCmdBuildStarted = formData.optString(
"gerritVerifiedCmdBuildStarted",
"gerrit review <CHANGE>,<PATCHSET> --message 'Build Started <BUILDURL> <STARTED_STATS>' "
"gerrit review --project <GERRIT_NAME> <CHANGE>,<PATCHSET> "
+ "--message 'Build Started <BUILDURL> <STARTED_STATS>' "
+ "--verified <VERIFIED> --code-review <CODE_REVIEW> --tag " + Constants.TAG_VALUE);
gerritVerifiedCmdBuildFailed = formData.optString(
"gerritVerifiedCmdBuildFailed",
"gerrit review <CHANGE>,<PATCHSET> --message 'Build Failed <BUILDS_STATS>' "
"gerrit review --project <GERRIT_NAME> <CHANGE>,<PATCHSET> "
+ "--message 'Build Failed <BUILDS_STATS>' "
+ "--verified <VERIFIED> --code-review <CODE_REVIEW> --tag " + Constants.TAG_VALUE);
gerritVerifiedCmdBuildSuccessful = formData.optString(
"gerritVerifiedCmdBuildSuccessful",
"gerrit review <CHANGE>,<PATCHSET> --message 'Build Successful <BUILDS_STATS>' "
"gerrit review --project <GERRIT_NAME> <CHANGE>,<PATCHSET> "
+ "--message 'Build Successful <BUILDS_STATS>' "
+ "--verified <VERIFIED> --code-review <CODE_REVIEW> --tag " + Constants.TAG_VALUE);
gerritVerifiedCmdBuildUnstable = formData.optString(
"gerritVerifiedCmdBuildUnstable",
"gerrit review <CHANGE>,<PATCHSET> --message 'Build Unstable <BUILDS_STATS>' "
"gerrit review --project <GERRIT_NAME> <CHANGE>,<PATCHSET> "
+ "--message 'Build Unstable <BUILDS_STATS>' "
+ "--verified <VERIFIED> --code-review <CODE_REVIEW> --tag " + Constants.TAG_VALUE);
gerritVerifiedCmdBuildNotBuilt = formData.optString(
"gerritVerifiedCmdBuildNotBuilt",
"gerrit review <CHANGE>,<PATCHSET> --message 'No Builds Executed <BUILDS_STATS>' "
"gerrit review --project <GERRIT_NAME> <CHANGE>,<PATCHSET> "
+ "--message 'No Builds Executed <BUILDS_STATS>' "
+ "--verified <VERIFIED> --code-review <CODE_REVIEW> --tag " + Constants.TAG_VALUE);
gerritVerifiedCmdBuildAborted = formData.optString(
"gerritVerifiedCmdBuildAborted",
"gerrit review <CHANGE>,<PATCHSET> --message 'Build Aborted <BUILDS_STATS>' "
"gerrit review --project <GERRIT_NAME> <CHANGE>,<PATCHSET> "
+ "--message 'Build Aborted <BUILDS_STATS>' "
+ "--verified <VERIFIED> --code-review <CODE_REVIEW> --tag " + Constants.TAG_VALUE);
gerritFrontEndUrl = formData.optString(
"gerritFrontEndUrl",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,37 +217,37 @@
help="/plugin/gerrit-trigger/help-GerritVerifiedCmdBuildStarted.html">
<f:textarea name="gerritVerifiedCmdBuildStarted"
value="${it.config.gerritCmdBuildStarted}"
default="gerrit review &lt;CHANGE&gt;,&lt;PATCHSET&gt; --message 'Build Started &lt;BUILDURL&gt; &lt;STARTED_STATS&gt;' --verified &lt;VERIFIED&gt; --code-review &lt;CODE_REVIEW&gt;"/>
default="gerrit review --project &lt;GERRIT_NAME&gt; &lt;CHANGE&gt;,&lt;PATCHSET&gt; --message 'Build Started &lt;BUILDURL&gt; &lt;STARTED_STATS&gt;' --verified &lt;VERIFIED&gt; --code-review &lt;CODE_REVIEW&gt;"/>
</f:entry>
<f:entry title="${%Successful}"
help="/plugin/gerrit-trigger/help-GerritVerifiedCmdBuildSuccessful.html">
<f:textarea name="gerritVerifiedCmdBuildSuccessful"
value="${it.config.gerritCmdBuildSuccessful}"
default="gerrit review &lt;CHANGE&gt;,&lt;PATCHSET&gt; --message 'Build Successful &lt;BUILDS_STATS&gt;' --verified &lt;VERIFIED&gt; --code-review &lt;CODE_REVIEW&gt;"/>
default="gerrit review --project &lt;GERRIT_NAME&gt; &lt;CHANGE&gt;,&lt;PATCHSET&gt; --message 'Build Successful &lt;BUILDS_STATS&gt;' --verified &lt;VERIFIED&gt; --code-review &lt;CODE_REVIEW&gt;"/>
</f:entry>
<f:entry title="${%Failed}"
help="/plugin/gerrit-trigger/help-GerritVerifiedCmdBuildFailed.html">
<f:textarea name="gerritVerifiedCmdBuildFailed"
value="${it.config.gerritCmdBuildFailed}"
default="gerrit review &lt;CHANGE&gt;,&lt;PATCHSET&gt; --message 'Build Failed &lt;BUILDS_STATS&gt;' --verified &lt;VERIFIED&gt; --code-review &lt;CODE_REVIEW&gt;"/>
default="gerrit review --project &lt;GERRIT_NAME&gt; &lt;CHANGE&gt;,&lt;PATCHSET&gt; --message 'Build Failed &lt;BUILDS_STATS&gt;' --verified &lt;VERIFIED&gt; --code-review &lt;CODE_REVIEW&gt;"/>
</f:entry>
<f:entry title="${%Unstable}"
help="/plugin/gerrit-trigger/help-GerritVerifiedCmdBuildUnstable.html">
<f:textarea name="gerritVerifiedCmdBuildUnstable"
value="${it.config.gerritCmdBuildUnstable}"
default="gerrit review &lt;CHANGE&gt;,&lt;PATCHSET&gt; --message 'Build Unstable &lt;BUILDS_STATS&gt;' --verified &lt;VERIFIED&gt; --code-review &lt;CODE_REVIEW&gt;"/>
default="gerrit review --project &lt;GERRIT_NAME&gt; &lt;CHANGE&gt;,&lt;PATCHSET&gt; --message 'Build Unstable &lt;BUILDS_STATS&gt;' --verified &lt;VERIFIED&gt; --code-review &lt;CODE_REVIEW&gt;"/>
</f:entry>
<f:entry title="${%Not Built}"
help="/plugin/gerrit-trigger/help-GerritVerifiedCmdBuildNotBuilt.html">
<f:textarea name="gerritVerifiedCmdBuildNotBuilt"
value="${it.config.gerritCmdBuildNotBuilt}"
default="gerrit review &lt;CHANGE&gt;,&lt;PATCHSET&gt; --message 'No Builds Executed &lt;BUILDS_STATS&gt;' --verified &lt;VERIFIED&gt; --code-review &lt;CODE_REVIEW&gt;"/>
default="gerrit review --project &lt;GERRIT_NAME&gt; &lt;CHANGE&gt;,&lt;PATCHSET&gt; --message 'No Builds Executed &lt;BUILDS_STATS&gt;' --verified &lt;VERIFIED&gt; --code-review &lt;CODE_REVIEW&gt;"/>
</f:entry>
<f:entry title="${%Aborted}"
help="/plugin/gerrit-trigger/help-GerritVerifiedCmdBuildAborted.html">
<f:textarea name="gerritVerifiedCmdBuildAborted"
value="${it.config.gerritCmdBuildAborted}"
default="gerrit review &lt;CHANGE&gt;,&lt;PATCHSET&gt; --message 'Build Aborted &lt;BUILDS_STATS&gt;' --verified &lt;VERIFIED&gt; --code-review &lt;CODE_REVIEW&gt;"/>
default="gerrit review --project &lt;GERRIT_NAME&gt; &lt;CHANGE&gt;,&lt;PATCHSET&gt; --message 'Build Aborted &lt;BUILDS_STATS&gt;' --verified &lt;VERIFIED&gt; --code-review &lt;CODE_REVIEW&gt;"/>
</f:entry>
</f:section>
<f:section title="${%Miscellaneous}">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,18 @@ public class ConfigTest {
*/
@Test
public void testSetValues() {
String formString = "{\"gerritVerifiedCmdBuildFailed\":\"gerrit review <CHANGE>,<PATCHSET> "
String formString = "{\"gerritVerifiedCmdBuildFailed\":"
+ "\"gerrit review --project <GERRIT_NAME> <CHANGE>,<PATCHSET> "
+ "--message 'Failed misserably <BUILDURL>' --verified <VERIFIED> --code-review <CODE_REVIEW>\","
+ "\"gerritVerifiedCmdBuildStarted\":\"gerrit review <CHANGE>,<PATCHSET> "
+ "\"gerritVerifiedCmdBuildStarted\":\"gerrit review --project <GERRIT_NAME> <CHANGE>,<PATCHSET> "
+ "--message 'Started yay!! <BUILDURL>' --verified <VERIFIED> --code-review <CODE_REVIEW>\","
+ "\"gerritVerifiedCmdBuildSuccessful\":\"gerrit review <CHANGE>,<PATCHSET>"
+ "\"gerritVerifiedCmdBuildSuccessful\":\"gerrit review --project <GERRIT_NAME> <CHANGE>,<PATCHSET>"
+ " --message 'Successful wonderful <BUILDURL>' --verified <VERIFIED> --code-review <CODE_REVIEW>\","
+ "\"gerritVerifiedCmdBuildUnstable\":\"gerrit review <CHANGE>,<PATCHSET> "
+ "\"gerritVerifiedCmdBuildUnstable\":\"gerrit review --project <GERRIT_NAME> <CHANGE>,<PATCHSET> "
+ "--message 'Unstable and you are to <BUILDURL>' --verified <VERIFIED> --code-review <CODE_REVIEW>\","
+ "\"gerritVerifiedCmdBuildNotBuilt\":\"gerrit review <CHANGE>,<PATCHSET> "
+ "\"gerritVerifiedCmdBuildNotBuilt\":\"gerrit review --project <GERRIT_NAME> <CHANGE>,<PATCHSET> "
+ "--message 'You are not built for it <BUILDURL>' --verified <VERIFIED> --code-review <CODE_REVIEW>\","
+ "\"gerritVerifiedCmdBuildAborted\":\"gerrit review <CHANGE>,<PATCHSET> "
+ "\"gerritVerifiedCmdBuildAborted\":\"gerrit review --project <GERRIT_NAME> <CHANGE>,<PATCHSET> "
+ "--message 'Aborted oupsy <BUILDURL>' --verified <VERIFIED> --code-review <CODE_REVIEW>\","
+ "\"gerritAuthKeyFile\":\"/home/local/gerrit/.ssh/id_rsa\","
+ "\"gerritAuthKeyFilePassword\":\"passis\","
Expand All @@ -100,24 +101,24 @@ public void testSetValues() {
+ "\"notificationLevel\":\"OWNER\"}";
JSONObject form = (JSONObject)JSONSerializer.toJSON(formString);
Config config = new Config(form);
assertEquals("gerrit review <CHANGE>,<PATCHSET> "
assertEquals("gerrit review --project <GERRIT_NAME> <CHANGE>,<PATCHSET> "
+ "--message 'Failed misserably <BUILDURL>' --verified <VERIFIED> --code-review <CODE_REVIEW>",
config.getGerritCmdBuildFailed());
assertEquals("gerrit review <CHANGE>,<PATCHSET> "
assertEquals("gerrit review --project <GERRIT_NAME> <CHANGE>,<PATCHSET> "
+ "--message 'Started yay!! <BUILDURL>' --verified <VERIFIED> --code-review <CODE_REVIEW>",
config.getGerritCmdBuildStarted());
assertEquals("gerrit review <CHANGE>,<PATCHSET>"
assertEquals("gerrit review --project <GERRIT_NAME> <CHANGE>,<PATCHSET>"
+ " --message 'Successful wonderful <BUILDURL>' --verified <VERIFIED> --code-review <CODE_REVIEW>",
config.getGerritCmdBuildSuccessful());
assertEquals("gerrit review <CHANGE>,<PATCHSET> "
assertEquals("gerrit review --project <GERRIT_NAME> <CHANGE>,<PATCHSET> "
+ "--message 'Unstable and you are to <BUILDURL>' --verified <VERIFIED> --code-review <CODE_REVIEW>",
config.getGerritCmdBuildUnstable());
assertEquals("gerrit review <CHANGE>,<PATCHSET> "
assertEquals("gerrit review --project <GERRIT_NAME> <CHANGE>,<PATCHSET> "
+ "--message 'You are not built for it <BUILDURL>' --verified <VERIFIED> --code-review <CODE_REVIEW>",
config.getGerritCmdBuildNotBuilt());
assertEquals("gerrit review <CHANGE>,<PATCHSET> "
+ "--message 'Aborted oupsy <BUILDURL>' --verified <VERIFIED> --code-review <CODE_REVIEW>",
config.getGerritCmdBuildAborted());
assertEquals("gerrit review --project <GERRIT_NAME> <CHANGE>,<PATCHSET> "
+ "--message 'Aborted oupsy <BUILDURL>' --verified <VERIFIED> --code-review <CODE_REVIEW>",
config.getGerritCmdBuildAborted());
assertEquals(new File("/home/local/gerrit/.ssh/id_rsa").getPath(),
config.getGerritAuthKeyFile().getPath());
assertEquals("passis", config.getGerritAuthKeyFilePassword());
Expand Down Expand Up @@ -167,17 +168,18 @@ public void testProjectListRefreshIntervalZeroValue() {
*/
@Test
public void testCopyConfig() {
String formString = "{\"gerritVerifiedCmdBuildFailed\":\"gerrit review <CHANGE>,<PATCHSET> "
String formString = "{\"gerritVerifiedCmdBuildFailed\":"
+ "\"gerrit review --project <GERRIT_NAME> <CHANGE>,<PATCHSET> "
+ "--message 'Failed misserably <BUILDURL>' --verified <VERIFIED> --code-review <CODE_REVIEW>\","
+ "\"gerritVerifiedCmdBuildStarted\":\"gerrit review <CHANGE>,<PATCHSET> "
+ "\"gerritVerifiedCmdBuildStarted\":\"gerrit review --project <GERRIT_NAME> <CHANGE>,<PATCHSET> "
+ "--message 'Started yay!! <BUILDURL>' --verified <VERIFIED> --code-review <CODE_REVIEW>\","
+ "\"gerritVerifiedCmdBuildSuccessful\":\"gerrit review <CHANGE>,<PATCHSET>"
+ "\"gerritVerifiedCmdBuildSuccessful\":\"gerrit review --project <GERRIT_NAME> <CHANGE>,<PATCHSET>"
+ " --message 'Successful wonderful <BUILDURL>' --verified <VERIFIED> --code-review <CODE_REVIEW>\","
+ "\"gerritVerifiedCmdBuildUnstable\":\"gerrit review <CHANGE>,<PATCHSET> "
+ "\"gerritVerifiedCmdBuildUnstable\":\"gerrit review --project <GERRIT_NAME> <CHANGE>,<PATCHSET> "
+ "--message 'Unstable and you are to <BUILDURL>' --verified <VERIFIED> --code-review <CODE_REVIEW>\","
+ "\"gerritVerifiedCmdBuildNotBuilt\":\"gerrit review <CHANGE>,<PATCHSET> "
+ "\"gerritVerifiedCmdBuildNotBuilt\":\"gerrit review --project <GERRIT_NAME> <CHANGE>,<PATCHSET> "
+ "--message 'You are not built for it <BUILDURL>' --verified <VERIFIED> --code-review <CODE_REVIEW>\","
+ "\"gerritVerifiedCmdBuildAborted\":\"gerrit review <CHANGE>,<PATCHSET> "
+ "\"gerritVerifiedCmdBuildAborted\":\"gerrit review --project <GERRIT_NAME> <CHANGE>,<PATCHSET> "
+ "--message 'Aborted oupsy <BUILDURL>' --verified <VERIFIED> --code-review <CODE_REVIEW>\","
+ "\"gerritAuthKeyFile\":\"/home/local/gerrit/.ssh/id_rsa\","
+ "\"gerritAuthKeyFilePassword\":\"passis\","
Expand Down Expand Up @@ -205,22 +207,22 @@ public void testCopyConfig() {
JSONObject form = (JSONObject)JSONSerializer.toJSON(formString);
Config initialConfig = new Config(form);
Config config = new Config(initialConfig);
assertEquals("gerrit review <CHANGE>,<PATCHSET> "
assertEquals("gerrit review --project <GERRIT_NAME> <CHANGE>,<PATCHSET> "
+ "--message 'Failed misserably <BUILDURL>' --verified <VERIFIED> --code-review <CODE_REVIEW>",
config.getGerritCmdBuildFailed());
assertEquals("gerrit review <CHANGE>,<PATCHSET> "
assertEquals("gerrit review --project <GERRIT_NAME> <CHANGE>,<PATCHSET> "
+ "--message 'Started yay!! <BUILDURL>' --verified <VERIFIED> --code-review <CODE_REVIEW>",
config.getGerritCmdBuildStarted());
assertEquals("gerrit review <CHANGE>,<PATCHSET>"
assertEquals("gerrit review --project <GERRIT_NAME> <CHANGE>,<PATCHSET>"
+ " --message 'Successful wonderful <BUILDURL>' --verified <VERIFIED> --code-review <CODE_REVIEW>",
config.getGerritCmdBuildSuccessful());
assertEquals("gerrit review <CHANGE>,<PATCHSET> "
assertEquals("gerrit review --project <GERRIT_NAME> <CHANGE>,<PATCHSET> "
+ "--message 'Unstable and you are to <BUILDURL>' --verified <VERIFIED> --code-review <CODE_REVIEW>",
config.getGerritCmdBuildUnstable());
assertEquals("gerrit review <CHANGE>,<PATCHSET> "
assertEquals("gerrit review --project <GERRIT_NAME> <CHANGE>,<PATCHSET> "
+ "--message 'You are not built for it <BUILDURL>' --verified <VERIFIED> --code-review <CODE_REVIEW>",
config.getGerritCmdBuildNotBuilt());
assertEquals("gerrit review <CHANGE>,<PATCHSET> "
assertEquals("gerrit review --project <GERRIT_NAME> <CHANGE>,<PATCHSET> "
+ "--message 'Aborted oupsy <BUILDURL>' --verified <VERIFIED> --code-review <CODE_REVIEW>",
config.getGerritCmdBuildAborted());
assertEquals(new File("/home/local/gerrit/.ssh/id_rsa").getPath(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,10 @@ public void testVoteSameTopic() throws Exception {
//CS IGNORE MagicNumber FOR NEXT 4 LINES. REASON: Testdata.
server.waitForCommand("gerrit stream-events", 2000);
triggerAndWait(projects[0]);
checkCommand("gerrit review 100,1 --message 'Build Started[\\s\\S.]*");
checkCommand("gerrit review 101,1 --message 'Build Started[\\s\\S.]*");
checkCommand("gerrit review 100,1 --message 'Build Successful[\\s\\S.]*");
checkCommand("gerrit review 101,1 --message 'Build Successful[\\s\\S.]*");
checkCommand("gerrit review --project " + projects[0] + " 100,1 --message 'Build Started[\\s\\S.]*");
checkCommand("gerrit review --project " + projects[1] + " 101,1 --message 'Build Started[\\s\\S.]*");
checkCommand("gerrit review --project " + projects[0] + " 100,1 --message 'Build Successful[\\s\\S.]*");
checkCommand("gerrit review --project " + projects[1] + " 101,1 --message 'Build Successful[\\s\\S.]*");
}

/**
Expand Down
Loading

0 comments on commit 20643d8

Please sign in to comment.