Created
July 24, 2013 17:41
-
-
Save scottbyrns/6072734 to your computer and use it in GitHub Desktop.
Java Redist Aspect Messenger + Jenkins & Local Automation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class JenkinsController | |
{ | |
public static String METRIC = "m", STANDARD = "s"; | |
@RegisterAsCallback( | |
group = "jenkins", | |
channel = "What is the high today?" | |
) | |
public void checkWeather (Message message) { | |
String zip = "83702"; | |
int days = 1; | |
String unit = STANDARD; | |
String partnerId = ""; | |
String licenseKey = "936aaec0946a8e33"; | |
try { | |
// ComputerVoice.speak("Please Check the local weather", ComputerVoice.VICTORIA); | |
HttpResponse<JsonNode> request = Unirest.get("https://george-vustrey-weather.p.mashape.com/api.php?_method=getForecasts&location=43,-116") | |
.header("X-Mashape-Authorization", | |
"rxpnzgm75swbhavzfrcgn9tstuomvb") | |
.asJson(); | |
ComputerVoice.speak(".. The current expected high is " + ((JSONObject)request.getBody().getArray().get(0)).getString("high") + " degrees.", ComputerVoice.ALEX); | |
} | |
catch (Exception e) { | |
e.printStackTrace(); | |
} | |
} | |
@RegisterAsCallback( | |
group = "jenkins", | |
channel = "Email Scott" | |
) | |
public void emailScott (Message message) { | |
try { | |
ComputerVoice.speak("Please... Will you send Scott a test email?", ComputerVoice.VICTORIA); | |
ComputerVoice.speak(".... Writting it now.", | |
ComputerVoice.BRUCE); | |
SendEmail.sendEmail("Email Test", | |
"Content delivered."); | |
ComputerVoice.speak("Test email sent.", ComputerVoice.ALEX); | |
} | |
catch (Exception e) { | |
e.printStackTrace(); | |
} | |
} | |
@RegisterAsCallback( | |
group = "jenkins", | |
channel = "What is the systems status?" | |
) | |
public void reportSystemStatus (Message message) { | |
ComputerVoice.speak("a... What is the JVM status?", ComputerVoice.VICTORIA); | |
/* Total number of processors or cores available to the JVM */ | |
ComputerVoice.speak("Available processors (cores): " + | |
Runtime.getRuntime().availableProcessors(), ComputerVoice.ALEX); | |
/* Total amount of free memory available to the JVM */ | |
ComputerVoice.speak("Free memory . " + | |
(Runtime.getRuntime().freeMemory() / 1024 / 1024) + " mega bytes", ComputerVoice.ALEX); | |
// Runtime.getRuntime().exec("") | |
} | |
@RegisterAsCallback( | |
group = "jenkins", | |
channel = "execute build" | |
) | |
public void executeBuild (Message message) { | |
if (message.getData() instanceof String) { | |
final String jobPath = "http://localhost:8080/job/" + ((String)message.getData()).replace(" ", "%20") + "/build"; | |
new Thread(new Runnable() | |
{ | |
public void run() | |
{ | |
try { | |
URL url = new URL(jobPath); | |
url.openConnection().getInputStream(); | |
} | |
catch (Exception e) { | |
e.printStackTrace(); | |
} | |
} | |
}).start(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment