You can define this as its own job in the “Job Library” folder and include it as a last step of any workflow you want to generate a one page report for. Create a job with one step that does Miscellaneous -> Evaluate Script.

 

Then, paste in the beanshell script as such:

 

Now you can include this step in any workflow, and it will create a report in the “Reports” tab of the build-life dashboard called “Installation Report”.

 

import com.urbancode.anthill3.domain.jobtrace.*;
import com.urbancode.anthill3.domain.workflow.*;
import com.urbancode.anthill3.domain.buildlife.BuildLife;
import com.urbancode.anthill3.domain.buildlife.BuildLifeFactory;
import com.urbancode.anthill3.domain.workflow.*;
import com.urbancode.anthill3.domain.agent.*;

import com.urbancode.anthill3.runtime.*;
import com.urbancode.devilfish.services.*;

import java.io.*;
import java.util.*;
import com.urbancode.commons.fileutils.FileUtils;


private String getStreamAsString(InputStream inStream)
	throws IOException {
	StringBuffer result = new StringBuffer();
	try {
		byte[] buffer = new byte[4096];
		int length = 0;
		while ((length = inStream.read(buffer)) > 0) {
			result.append(new String(buffer, 0, length));
		}
	} finally {
		try {
			inStream.close();
		} catch (Exception e) {
		}
	}
		return result.toString();
}

WorkflowCase workflow = WorkflowLookup.getCurrentCase();
JobTrace[] jobTraces = workflow.getJobTraceArray();
JobTrace jobTrace = JobTraceLookup.getCurrent();
String publishPath = VarService.getInstance().resolve(PublishPathHelper.getInstance().getPublishPath(jobTrace, "Installation Report"));
FileUtils.assertDirectory(publishPath);
File reportFile = new File(publishPath, "installation-report.html");
BufferedWriter writer = new BufferedWriter(new FileWriter(reportFile));

writer.write(
	"<HTML>\n" + "<HEAD>\n" +"<TITLE>Anthill3 - Installation Report</TITLE>\n" +
	"<link rel=\"StyleSheet\" href=\"/css/anthill3.css\" type=\"text/css\">" +
	"</head>\n" + "<BODY>\n" + "<TABLE class=\"data-table\" WIDTH=\"100%\">\n" + "\n" + "<TR><TD colspan=2>\n" +
	"<H1>Installation Report</H1>\n" + "</TD></TR>\n"
);

for (int j=0; j<jobTraces.length; j++){
	Agent thisAgent = jobTraces[j].getAgent();
	writer.write(
		"<TR><TD colspan=2 valign=top>JOB NAME: " + jobTraces[j].name + "<BR>" + "<b>Agent Name:</b> " + thisAgent.getName() + "<BR><b>Agent Hostname:</b> " + thisAgent.getHostname() + "</td></tr>"
	);
	StepTrace[] stepTraces = jobTraces[j].getStepTraceArray();
	for (int s=0; s<stepTraces.length; s++) {
		writer.write("
			<tr><td valign=top><b>Step:</b><BR> " + stepTraces[s].getName() + "<BR><b>Agent Name:</b> " + thisAgent.getName() + "<BR><b>Agent Hostname:</b> " + thisAgent.getHostname() + "</td>
		");
		
		try{
			CommandTrace cmdTrace = stepTraces[s].getCommandTraceArray()[0];
			FileInfo outputFile = LogPathHelper.getInstance().getLogFileInfoArray(cmdTrace)[0];
			InputStream inStream = FileInfoService.getInstance().getFileInfoAsStream(outputFile);
			String output = getStreamAsString(inStream);
			writer.write(
                                 // change /pr3 to /pre below. Thanks!
				"<td valign=top><pre>" + output + "</pr3></td></tr>"
			);
		}catch(Exception e) {
			writer.write(
				"<td valign=top><b>NO OUTPUT</b></td></tr>"
			);
			continue;
		}
	}
}
writer.write("</table></body></html>");
writer.flush();
writer.close();

 

You can download the beanshell script here.