Skip to content

Commit

Permalink
Initial Upload
Browse files Browse the repository at this point in the history
* Initial Upload

* Added Automation folder

* Added Snippets folder

* Initial Upload

* Create CONTRIBUTIONS.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Create README.md

* Update CONTRIBUTIONS.md

* Update README.md

* Update CONTRIBUTIONS.md
  • Loading branch information
drbruce-github authored and drbruce-git committed Oct 1, 2018
1 parent c6166da commit 59d305a
Show file tree
Hide file tree
Showing 107 changed files with 10,214 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Automation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Automation
This category contains examples of using DBB to easily automate common DevOps tasks on z/OS.
11 changes: 11 additions & 0 deletions Build/BuildReport/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>BuildReport</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
</projectDescription>
39 changes: 39 additions & 0 deletions Build/BuildReport/BuildReport.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!DOCTYPE html>
<html>

<head>
<style type="text/css">
<!-- %CSS_STYLES_GO_HERE% -->
</style>
</head>

<body>
<h2>Build Report</h2>
<p id="main"></p>

<script type="text/javascript">
var buildReportFile = "";
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = render;
xmlhttp.open("GET", buildReportFile, true);
xmlhttp.send();

function toggle(dep, text)
{
if (document.getElementById(text).text == 'Show Dependencies')
document.getElementById(text).text = 'Hide Dependencies';
else
document.getElementById(text).text = 'Show Dependencies';

if (document.getElementById(dep).style.display == 'none')
document.getElementById(dep).style.display = 'block';
else
document.getElementById(dep).style.display = 'none';
};

/* %RENDER_SCRIPT_GO_HERE% */

</script>

</body>
</html>
201 changes: 201 additions & 0 deletions Build/BuildReport/BuildSummaryRender.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
function render()
{
if (this.readyState == 4 && (this.status == 200 || this.status == 0))
{
var prevFile = "";
var nextFile = "";
var counter = 1;
var tableHtml = "";
var jenkinsBuildHtml = "";
var cRecord;
var jenkinsWorkspace;
var jenkinsJobUrl;
var versionInfoHtml = "";
var dependencySetCache = new Object();
var buildReport = JSON.parse(this.responseText);
/** Add a new header to display the Git commit hash value */
tableHtml += "<table><tr><th></th><th>File</th><th>Git Hash</th><th>Commands</th><th>RC</th><th>Data Sets</th><th>Outputs</th><th>Deploy Type</th><th>Logs</th></tr>";
for (x in buildReport.records)
{
var record = buildReport.records[x];
if (record.type == "EXECUTE")
{
nextFile = record.file;

//If we are coming across different file for the current EXECUTE record
//then display the last processing consolidated record and generate a new
//consolidated record.
if (prevFile == "" || prevFile != nextFile)
{
if (cRecord != null)
{
tableHtml += renderExec(counter, cRecord, dependencySetCache);
counter++;
}

//Reset the consolidate record
cRecord = new Object();
cRecord.file = record.file;
cRecord.executors = [];
cRecord.rcs = [];
cRecord.datasets = [];
cRecord.outputs = [];
cRecord.deployTypes = [];
cRecord.logs = [];
cRecord.logFiles = []; /* maintain this to avoid having duplicated log files for each file */
cRecord.gitHash = ""; /** Reset the commit Git hash value before parsing the next record */
}
var numExecutors = cRecord.executors.length;
cRecord.executors[numExecutors] = record.command;
cRecord.rcs[numExecutors] = record.rc;
cRecord.outputs[numExecutors] = "";
cRecord.deployTypes[numExecutors] = "";
for (z in record.outputs)
{
var output = record.outputs[z];
if (cRecord.outputs[numExecutors].length > 0)
{
cRecord.outputs[numExecutors] += "<br>";
cRecord.deployTypes[numExecutors] += "<br>";
}
cRecord.outputs[numExecutors] += output.dataset;
if (output.deployType != null)
cRecord.deployTypes[numExecutors] += output.deployType;
else cRecord.deployTypes[numExecutors] += "&nbsp;";

}
cRecord.datasets[numExecutors] = "";
for (m in record.datasets)
{
var dataset = record.datasets[m];
if (cRecord.datasets[numExecutors].length > 0)
cRecord.datasets[numExecutors] += "<br>";
cRecord.datasets[numExecutors] += dataset;
}
cRecord.logs[numExecutors] = "";
for (n in record.logs)
{
var log = record.logs[n];
var duplicateLog = false;
for (p in cRecord.logFiles)
{
if (log == cRecord.logFiles[p])
{
duplicateLog = true;
break;
}
}

if (!duplicateLog)
{
if (cRecord.logs[numExecutors].length > 0)
cRecord.logs[numExecutors] += "<br>";
var logName = log.split(/[\\/]/g).pop();
if (jenkinsJobUrl != null && jenkinsWorkspace != null && log.startsWith(jenkinsWorkspace))
{
var logLink = "<a href='" + jenkinsJobUrl + "ws" + log.slice(jenkinsWorkspace.length) + "/*view*/' target='_blank'>" + logName + "</a>";
cRecord.logs[numExecutors] = logLink;
}
else
{
cRecord.logs[numExecutors] += logName;
}
cRecord.logFiles[cRecord.logFiles.length] = log;
}
}
prevFile = nextFile;
}
else if (record.type == 'JENKINS')
{
jenkinsBuildHtml += "<div id='jenkins'><p><h3>Jenkins Build</h3>";
jenkinsBuildHtml += "<p><table><tr><td class='label'>Project: </td><td><a href='" + record.jobUrl + "'>" + record.jobName + "</a></td></tr>";
jenkinsBuildHtml += "<tr><td class='label'>Build: </td><td><a href='" + record.buildUrl + "'>" + record.buildNumber + "</a></td></tr>";
jenkinsBuildHtml += "<tr><td class='label'>Workspace: </td><td>" + record.workspace + "</td></tr></table></div>";
if (jenkinsWorkspace == null)
jenkinsWorkspace = record.workspace;
if (jenkinsJobUrl == null)
jenkinsJobUrl = record.jobUrl;
}
else if (record.type == 'DEPENDENCY_SET')
{
if (record.dependencySet != null && record.dependencySet.length > 0)
dependencySetCache[record.file] = record.dependencySet;
}
else if (record.type == 'VERSION')
{
versionInfoHtml = "<div id='VersionInfo'><p><h3>Toolkit Version:</h3></p>";
versionInfoHtml += "<p><table><tr><td class='label'>Version: </td><td>" + record.version + "</td></tr>";
versionInfoHtml += "<tr><td class='label'>Build: </td><td>" + record.build + "</td></tr>";
versionInfoHtml += "<tr><td class='label'>Date: </td><td>" + record.date + "</td></tr></table></div>"
}
/** Parse the Git commit hash value for each file */
else if (record.type == 'GIT_HASH')
{
cRecord.gitHash = record.commitHashValue
}
}

if (cRecord != null)
{
tableHtml += renderExec(counter, cRecord, dependencySetCache);
counter++;
}

tableHtml += "</table>";
var mainHtml = "<div id='main'>";
var buildSummaryHtml = "<div id='buildSummary'>";
buildSummaryHtml += "<p><h3>Build Summary</h3><p>Number of files being built: " + (counter-1);
buildSummaryHtml += "<p>" + tableHtml + "</div>";
mainHtml += versionInfoHtml;
mainHtml += jenkinsBuildHtml;
mainHtml += buildSummaryHtml;
mainHtml += "</div>";
document.getElementById("main").innerHTML = mainHtml;
}
}

function renderExec(counter, cRecord, dependencySetCache)
{
var tr = "<tr>";
if (counter % 2 == 0)
tr = "<tr class='even'>";
var rowHtml = tr;
rowHtml += "<td rowspan='" + cRecord.executors.length + "'>" + counter + "</td><td rowspan='" + cRecord.executors.length + "'>" + cRecord.file;
var dependencySet = dependencySetCache[cRecord.file];
if (dependencySet != null)
{
var depId = "dep_" + counter;
var showDepId = "showDep_" + counter;
rowHtml += "<div>";
rowHtml += "<div id='" + depId + "' style='display:none' class='dep'>";
rowHtml += "<ul>";
for (q in dependencySet)
{
rowHtml += "<li>";
var dependency = dependencySet[q];
if (dependency.resolved)
rowHtml += dependency.file;
else
rowHtml += dependency.lname;
rowHtml += "&nbsp;<sub class='depType'>" + dependency.category + "</sub>";
rowHtml += "</li>";
}
rowHtml += "</div>";
rowHtml += "<a id='" + showDepId + "' class='bottomRight' href='javascript:onclick=toggle(\"" + depId + "\",\"" + showDepId + "\")'>Show Dependencies</a>";
rowHtml += "</div>";
}
rowHtml += "</td>";
/** Generate a HTML column to display the Git commit hash value for each file */
rowHtml += "<td rowspan='" + cRecord.executors.length + "'>" + cRecord.gitHash + "</td>";
var cRecordCount = 0;
for (y in cRecord.executors)
{
rowHtml += "<td>" + cRecord.executors[y] + "</td><td>" + cRecord.rcs[y] + "</td><td>" + cRecord.datasets[y] + "</td><td>";
rowHtml += cRecord.outputs[y] + "</td><td>" + cRecord.deployTypes[y] + "</td><td>" + cRecord.logs[y] + "</td>";
if (cRecordCount < cRecord.executors.length)
rowHtml += "</tr>" + tr;
cRecordCount++;
}
rowHtml += "</tr>";
return rowHtml;
}
44 changes: 44 additions & 0 deletions Build/BuildReport/DefaultTheme.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
body {
font: 12px Arial, sans-serif;
}

table {
border-collapse: collapse;
}

table, th, td {
border: 1px solid #A9A9A9;
}

th, td {
padding: 10px;
text-align: left;
}

tr.even {
background-color: #f2f2f2
}

th {
background-color: #81C4E8;
color: white;
}

td.label {
font-weight: bold;
}

.bottomRight {
float:right;
text-align:right;
font: 10px Arial, sans-serif;
}

.dep {
font: 11px Arial, sans-serif;
}

.depType {
font: 9px Arial, sans-serif;
background-color: #81C4E8;
}
90 changes: 90 additions & 0 deletions Build/BuildReport/GitHashRecord.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*******************************************************************************
* Licensed Materials - Property of IBM
* (c) Copyright IBM Corporation 2018. All Rights Reserved.
*
* Note to U.S. Government Users Restricted Rights:
* Use, duplication or disclosure restricted by GSA ADP Schedule
* Contract with IBM Corp.
*******************************************************************************/
package com.ibm.team.dbb.build.ext.git.report;

import com.ibm.json.java.JSONObject;
import com.ibm.team.dbb.build.report.records.Record;

/**
* Sample build report record to store Git hash information for
* each file
*
*/
public class GitHashRecord extends Record
{
public static final String PROP_FILE_PATH = "filePath";
public static final String PROP_COMMIT_HASH_VALUE = "commitHashValue";

private String filePath;
private String commitHashValue;

/**
* Constructor
*/
public GitHashRecord(String id)
{
super(id, GitRecordFactory.TYPE_GIT_HASH);
}

/**
* Return the path of the file
* @return the path of the file
*/
public String getFilePath()
{
return filePath;
}

/**
* Set the path of the file
* @param filePath the path of the file
*/
public void setFilePath(String filePath)
{
this.filePath = filePath;
}

/**
* Return the hash value of the file
* @return the hash value of the file
*/
public String getCommitHashValue()
{
return commitHashValue;
}

/**
* Set the hash value of the file
* @param commitHashValue the hash value of the file
*/
public void setCommitHashValue(String commitHashValue)
{
this.commitHashValue = commitHashValue;
}

@Override
public JSONObject toJSON()
{
JSONObject jsonObj = super.toJSON();
jsonObj.put(PROP_FILE_PATH, filePath);
jsonObj.put(PROP_COMMIT_HASH_VALUE, commitHashValue);
return jsonObj;
}

@Override
public Record parse(JSONObject jsonObj)
{
Record record = super.parse(jsonObj);
filePath = (String)jsonObj.get(PROP_FILE_PATH);
commitHashValue = (String)jsonObj.get(PROP_COMMIT_HASH_VALUE);
return record;
}


}
Loading

0 comments on commit 59d305a

Please sign in to comment.