Development teams need to keep track of builds on Jenkins and sometimes an email alert is not flashy enough. Using this simple javascript on your team dashboard you can easily track failed builds and urge developers to fix it.
The script uses Jenkins JSON API with JSONP method to request the latest failed builds with author name and last commit that caused the failure. You will need to add the domain of the page where the request is sent to your “Jenkins” “Configure Global Security” “Domains from which to allow requests” configuration. Also the cookie from Jenkins is needed on the same browser so you will need to login to Jenkins from the same browser before running the script or proxy the request and use Basic Authorization using your API token to do the request.
Simple way to replace URLs for proxied websites using mod filter and substitute
<VirtualHost *:80 >
ProxyPreserveHost On
ServerName proxy-test.example.com
FilterDeclare MYFILTER
FilterProvider MYFILTER SUBSTITUTE resp=Content-Type $text/
FilterProvider MYFILTER SUBSTITUTE resp=Content-Type $/xml
FilterProvider MYFILTER SUBSTITUTE resp=Content-Type $/json
FilterProvider MYFILTER SUBSTITUTE resp=Content-Type $/javascript
<Location />
#disable gzip
RequestHeader unset Accept-Encoding
FilterChain MYFILTER
Substitute "s!(images|static|test).example.com!proxy-$1.example.com!i"
</Location>
ProxyPass / http://test.example.com/
ProxyPassReverse / http://test.example.com/
</VirtualHost >
Modify on Gist tested on Firefox 7.0.1
const Ci = Components.interfaces;
const Cc = Components.classes;
function ReadWrite( data ){
try{
Components.utils.import("resource://gre/modules/NetUtil.jsm");
Components.utils.import("resource://gre/modules/FileUtils.jsm");
var file = FileUtils.getFile("ProfD", ["FileName.txt"]);
var ostream = FileUtils.openSafeFileOutputStream(file );
var converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"].
createInstance(Ci.nsIScriptableUnicodeConverter);
if( data ){
if ( !file.exists() ){
file.create( Ci.nsIFile.NORMAL_FILE_TYPE, 420);
}
converter.charset = "UTF-8";
var istream = converter.convertToInputStream(data);
NetUtil.asyncCopy(istream , ostream, function(status) {
if (!Components.isSuccessCode(status)) {
alert( "Error! :" + status );
return false;
}
});
}else{
var data = '';
var fstream = Cc["@mozilla.org/network/file-input-stream;1"].
createInstance(Ci.nsIFileInputStream);
var cstream = Cc["@mozilla.org/intl/converter-input-stream;1"].
createInstance(Ci.nsIConverterInputStream);
fstream.init(file, -1, 0, 0);
cstream.init(fstream, "UTF-8", 0, 0); // you can use another encoding here if you wish
let (str = {}) {
let read = 0;
do {
read = cstream.readString(0xffffffff, str); // read as much as we can and put it in str.value
data += str.value;
} while (read != 0);
}
cstream.close(); // this closes fstream
return data;
}
}catch(e){
// alert( e);
return false;
}
}