Skip to content

Commit e0ae79e

Browse files
authored
validateFieldConfigs json changed (#214)
* fix typo * seems json structure changed for publisher to JSONArray, adapted code to support that in case object is not found * revert Bump io.atlassian.fugue:fugue from 4.7.2 to 6.1.2 (#209) @dependabot[bot] Bump jira-rest-client.version from 5.2.6 to 6.0.1 (#152) @dependabot[bot] as they start to cause build issues * fix spotless issues
1 parent a6f8dc2 commit e0ae79e

File tree

4 files changed

+29
-6
lines changed

4 files changed

+29
-6
lines changed

pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@
5252
<!-- https://www.jenkins.io/doc/developer/plugin-development/choosing-jenkins-baseline/ -->
5353
<jenkins.baseline>2.479</jenkins.baseline>
5454
<jenkins.version>${jenkins.baseline}.3</jenkins.version>
55-
<jira-rest-client.version>6.0.1</jira-rest-client.version>
56-
<fugue.version>6.1.2</fugue.version>
55+
<jira-rest-client.version>5.2.8-platform7-12284590</jira-rest-client.version>
56+
<fugue.version>4.7.2</fugue.version>
5757
<gitHubRepo>jenkinsci/${project.artifactId}-plugin</gitHubRepo>
5858
<spotbugs.threshold>High</spotbugs.threshold>
5959
<spotless.check.skip>false</spotless.check.skip>

src/main/java/org/jenkinsci/plugins/JiraTestResultReporter/JiraTestDataPublisher.java

+25-2
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@
7272
import java.util.List;
7373
import java.util.Map;
7474
import jenkins.model.Jenkins;
75+
import net.sf.json.JSONArray;
76+
import net.sf.json.JSONException;
7577
import net.sf.json.JSONObject;
7678
import org.jenkinsci.Symbol;
7779
import org.jenkinsci.plugins.JiraTestResultReporter.config.AbstractFields;
@@ -802,7 +804,28 @@ public FormValidation validateFieldConfigs(String jsonForm) throws FormException
802804
// extracting the configurations for associated with this plugin (we receive the entire form)
803805
StaplerRequest2 req = Stapler.getCurrentRequest2();
804806
JSONObject jsonObject = JSONObject.fromObject(jsonForm);
805-
JSONObject publishers = jsonObject.getJSONObject("publisher");
807+
JSONObject publishers = null;
808+
try {
809+
publishers = jsonObject.getJSONObject("publisher");
810+
} catch (JSONException e) {
811+
JiraUtils.log("Error finding key publisher, try with array as format changed");
812+
JSONArray publisherArray = jsonObject.getJSONArray("publisher");
813+
// find the first array element which contains testDataPublishers
814+
for (int i = 0; i < publisherArray.size(); i++) {
815+
JSONObject arrayObject = publisherArray.getJSONObject(i);
816+
for (Object o : arrayObject.keySet()) {
817+
if (o.toString().equals("testDataPublishers")) {
818+
publishers = arrayObject;
819+
break;
820+
}
821+
}
822+
}
823+
}
824+
825+
if (publishers == null) {
826+
return FormValidation.error("publisher object not found in json.\n");
827+
}
828+
806829
JSONObject jiraPublisherJSON = null;
807830

808831
for (Object o : publishers.keySet()) {
@@ -821,7 +844,7 @@ public FormValidation validateFieldConfigs(String jsonForm) throws FormException
821844
newInstancesFromHeteroList(req, jiraPublisherJSON.get("configs"), getListDescriptors());
822845
if (configs == null) {
823846
// nothing to validate
824-
return FormValidation.ok("OK!");
847+
return FormValidation.ok("OK! No validation done.");
825848
}
826849
String projectKey = jiraPublisherJSON.getString("projectKey");
827850
Long issueType = jiraPublisherJSON.getLong("issueType");

src/main/resources/org/jenkinsci/plugins/JiraTestResultReporter/config/StringArrayFields/help-value.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@
2525
<p>BUILD_RESULT</p>
2626

2727
<h3>WARNING: Your input will not be validated against the server's metadata. Check Jira to make sure you insert
28-
a valid value for this field and use the Validate Fields button bellow, otherwise the plugin will fail to create your issue.</h3>
28+
a valid value for this field and use the Validate Fields button below, otherwise the plugin will fail to create your issue.</h3>
2929
</div>

src/main/resources/org/jenkinsci/plugins/JiraTestResultReporter/config/StringFields/help-value.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@
2525
<p>BUILD_RESULT</p>
2626

2727
<h3>WARNING: Your input will not be validated against the server's metadata. Check Jira to make sure you insert
28-
a valid value for this field and use the Validate Fields button bellow, otherwise the plugin will fail to create your issue.</h3>
28+
a valid value for this field and use the Validate Fields button below, otherwise the plugin will fail to create your issue.</h3>
2929
</div>

0 commit comments

Comments
 (0)