Skip to content

Instantly share code, notes, and snippets.

@alexschwartz
Created April 10, 2011 22:14
Show Gist options
  • Save alexschwartz/912787 to your computer and use it in GitHub Desktop.
Save alexschwartz/912787 to your computer and use it in GitHub Desktop.
Ask Jenkins via json using jquery
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Seitenr?nder - marginwidth, marginheight, topmargin, leftmargin</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
var baseUrl;
var jobName;
$('button').click(function(){
baseUrl = $("#baseUrl").val();
jobName = $("#jobName").val();
jenkinsUrl = baseUrl + "/job/" + jobName + "/api/json?jsonp=?"
$("#jobUrl").append(jenkinsUrl)
$("#downstream").append("starting request");
$.getJSON(jenkinsUrl, function(json) {
$("#downstream").append("got callback: " + json.color);
});
});
});
</script>
</head>
<body marginwidth="50" marginheight="100" topmargin="100" leftmargin="50">
<h3>Input Data</h3>
Hudson/Jenkins Base URL:
<input type="text" id="baseUrl" value="http://localhost:8080" /><br/>
Hudson/Jenkins Job Name:
<input type="text" id="jobName" value="green"/><br/>
<button>update</button><br />
<h2>Output</h2>
<h3>Job URL</h3>
<div id="jobUrl">
</div>
<h3>Upstream Jobs</h3>
<div id="upstream">
</div>
<h3>Downstream Jobs</h3>
<div id="downstream">
</div>
</body></html>
@amynbe
Copy link

amynbe commented Jan 8, 2016

thanks for sharing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment