Skip to content

Instantly share code, notes, and snippets.

View kellyrob99's full-sized avatar

Kelly Robinson kellyrob99

View GitHub Profile
@kellyrob99
kellyrob99 / graphGenerator.groovy
Created April 23, 2012 01:57
Given a GraphViz dot file, create combinations of layouts and output formats; depends on having the dot executable preinstalled
import groovyx.gpars.GParsPool
def inputfile = args[0]
def layouts = [ 'twopi', 'sfdp', 'osage']
def formats = [ 'pdf','svg']
def combinations = [layouts, formats].combinations()
GParsPool.withPool(4) {
combinations.eachParallel { combination ->
String layout = combination[0]
@kellyrob99
kellyrob99 / README.md
Created October 2, 2015 02:56 — forked from agnoster/README.md
My ZSH Theme

agnoster.zsh-theme

A ZSH theme optimized for people who use:

  • Solarized
  • Git
  • Unicode-compatible fonts and terminals (I use iTerm2 + Menlo)

For Mac users, I highly recommend iTerm 2 + Solarized Dark

@kellyrob99
kellyrob99 / findAndTriggerFailedBuilds.groovy
Created February 26, 2012 00:44
Find and trigger all failed builds on a machine
@GrabResolver(name = 'glassfish', root = 'http://maven.glassfish.org/content/groups/public/')
@GrabResolver(name = "github", root = "http://kellyrob99.github.com/Jenkins-api-tour/repository")
@Grab('org.kar:hudson-api:0.2-SNAPSHOT')
@GrabExclude('org.codehaus.groovy:groovy')
import org.kar.hudson.api.cli.HudsonCliApi
String rootUrl = 'http://localhost:8080'
HudsonCliApi cliApi = new HudsonCliApi()
OutputStream out = new ByteArrayOutputStream()
def script = '''hudson.items.findAll{ job ->
@kellyrob99
kellyrob99 / jenkinsGroovyShell.groovy
Created February 26, 2012 01:09
Launch an interactive Groovy shell to a Jenkins server
@GrabResolver(name = 'glassfish', root = 'http://maven.glassfish.org/content/groups/public/')
@GrabResolver(name = "github", root = "http://kellyrob99.github.com/Jenkins-api-tour/repository")
@Grab('org.kar:hudson-api:0.2-SNAPSHOT')
@GrabExclude('org.codehaus.groovy:groovy')
import org.kar.hudson.api.cli.HudsonCliApi
/**
* Open an interactive Groovy shell that imports the hudson.model.* classes and exposes
* a 'hudson' and/or 'jenkins' object in the Binding which is an instance of hudson.model.Hudson
*/
HudsonCliApi cliApi = new HudsonCliApi()
@kellyrob99
kellyrob99 / nameAllJobs.groovy
Created February 25, 2012 19:53
Call Jenkins CLI and return the names of all Jobs
@GrabResolver(name = 'glassfish', root = 'http://maven.glassfish.org/content/groups/public/')
@GrabResolver(name = "github", root = "http://kellyrob99.github.com/Jenkins-api-tour/repository")
@Grab('org.kar:hudson-api:0.2-SNAPSHOT')
@GrabExclude('org.codehaus.groovy:groovy')
import org.kar.hudson.api.cli.HudsonCliApi
String rootUrl = 'http://localhost:8080'
HudsonCliApi cliApi = new HudsonCliApi()
OutputStream out = new ByteArrayOutputStream()
cliApi.runCliCommand(rootUrl, ['groovysh', 'hudson.jobNames.inspect()'], System.in, out, System.err)
@kellyrob99
kellyrob99 / examineJenkinsCommands.groovy
Created February 25, 2012 18:18
Call Jenkins CLI command with no arguments to elicit the required arguments for each.
@GrabResolver(name = 'glassfish', root = 'http://maven.glassfish.org/content/groups/public/')
@GrabResolver(name = "github", root = "http://kellyrob99.github.com/Jenkins-api-tour/repository")
@Grab('org.kar:hudson-api:0.2-SNAPSHOT')
@GrabExclude('org.codehaus.groovy:groovy')
import static java.net.HttpURLConnection.*
import org.kar.hudson.api.*
import org.kar.hudson.api.cli.HudsonCliApi
String rootUrl = 'http://localhost:8080'
HudsonCliApi cliApi = new HudsonCliApi()
@kellyrob99
kellyrob99 / grettyGreenMailServer.groovy
Created December 28, 2011 02:06
Use Gretty to provide a JSON front end for a GreenMail smtp test server
@GrabResolver(name = 'gretty', root = 'http://groovypp.artifactoryonline.com/groovypp/libs-releases-local')
@Grab('org.mbte.groovypp:gretty:0.4.279')
@Grab('com.icegreen:greenmail:1.3.1b')
import javax.mail.internet.MimeMessage
import org.jboss.netty.channel.local.LocalAddress
import org.mbte.gretty.httpserver.GrettyServer
import com.icegreen.greenmail.user.*
import com.icegreen.greenmail.util.*
//create the greenmail server
import org.mbte.gretty.httpserver.*
@GrabResolver(name='gretty',
root='http://groovypp.artifactoryonline.com/groovypp/libs-releases-local')
@Grab('org.mbte.groovypp:gretty:0.4.279')
GrettyServer server = []
server.groovy = [
localAddress: new InetSocketAddress("localhost", 8080),
defaultHandler: {
@kellyrob99
kellyrob99 / jenkinsBuildArtifacts.groovy
Created December 4, 2011 18:07
Example of parsing out the artifacts of the last successful build on Jenkins/Hudson using the JSON api
import groovy.json.*
def HOSTNAME = 'http://ci.jruby.org'
def JOBNAME = 'jruby-dist'
def JOB_URL = "$HOSTNAME/job/$JOBNAME/lastSuccessfulBuild"
def text = "$JOB_URL/api/json".toURL().text
println JsonOutput.prettyPrint(text)
def json = new JsonSlurper().parseText(text)
json.artifacts.each{
println it
}
@kellyrob99
kellyrob99 / jenkinsSVNVersionChecker.groovy
Created December 4, 2011 18:03
A script to find the source control version of the last successful build on every Jenkins job for a particular server. Outputs whether or not each job is building the expectedVersion.
import groovy.json.JsonSlurper
assert args && args.size() == 2
def urls = args[0].split(',')
def expectedVersion = args[1]
urls.each { url ->
println "examining url $url"
def json = new JsonSlurper().parseText(url.toURL().text)
json.jobs.each {