Skip to content

Commit

Permalink
use plainer types for AnchoreAction members - Fixes JENKINS-48989
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Nurmi <nurmi@anchore.com>
  • Loading branch information
nurmi committed Jan 17, 2018
1 parent e2db0d9 commit e76d628
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
@@ -1,10 +1,11 @@
package com.anchore.jenkins.plugins.anchore;

import com.google.common.base.Function;
import com.google.common.collect.Maps;
//import com.google.common.collect.Maps;
import hudson.model.Action;
import hudson.model.Run;
import java.util.Map;
import java.util.HashMap;
import javax.annotation.Nullable;
import jenkins.model.Jenkins;
import net.sf.json.JSONObject;
Expand All @@ -20,7 +21,7 @@ public class AnchoreAction implements Action {
private String gateStatus;
private String gateOutputUrl;
private Map<String, String> queryOutputUrls;
private JSONObject gateSummary;
private String gateSummary;

// For backwards compatibility
@Deprecated
Expand All @@ -30,17 +31,29 @@ public class AnchoreAction implements Action {


public AnchoreAction(Run<?, ?> build, String gateStatus, final String jenkinsOutputDirName, String gateReport,
Map<String, String> queryReports, JSONObject gateSummary) {
Map<String, String> queryReports, String gateSummary) {
this.build = build;
this.gateStatus = gateStatus;
this.gateOutputUrl = "../artifact/" + jenkinsOutputDirName + "/" + gateReport;

this.queryOutputUrls = new HashMap<String, String>();
for (Map.Entry<String, String> entry : queryReports.entrySet()) {
String k = entry.getKey();
String v = entry.getValue();
String newv = "../artifact/" + jenkinsOutputDirName + "/" + v;
this.queryOutputUrls.put(k, newv);
}

// original maps conversion method
/*
this.queryOutputUrls = Maps.transformValues(queryReports, new Function<String, String>() {
@Override
public String apply(@Nullable String queryOutput) {
return "../artifact/" + jenkinsOutputDirName + "/" + queryOutput;
}
});
*/
this.gateSummary = gateSummary;
}

Expand Down Expand Up @@ -76,7 +89,8 @@ public Map<String, String> getQueryOutputUrls() {
}

public JSONObject getGateSummary() {
return gateSummary;
JSONObject ret = JSONObject.fromObject(gateSummary);
return ret;
}

public String getGateReportUrl() {
Expand Down
Expand Up @@ -820,9 +820,9 @@ public void setupBuildReports() throws AbortException {

if (finalAction != null) {
build.addAction(
new AnchoreAction(build, finalAction.toString(), jenkinsOutputDirName, gateOutputFileName, queryOutputMap, gateSummary));
new AnchoreAction(build, finalAction.toString(), jenkinsOutputDirName, gateOutputFileName, queryOutputMap, gateSummary.toString()));
} else {
build.addAction(new AnchoreAction(build, "", jenkinsOutputDirName, gateOutputFileName, queryOutputMap, gateSummary));
build.addAction(new AnchoreAction(build, "", jenkinsOutputDirName, gateOutputFileName, queryOutputMap, gateSummary.toString()));
}
// } catch (AbortException e) { // probably caught one of the thrown exceptions, let it pass through
// throw e;
Expand Down

0 comments on commit e76d628

Please sign in to comment.