Skip to content

Instantly share code, notes, and snippets.

View kellyrob99's full-sized avatar

Kelly Robinson kellyrob99

View GitHub Profile
@kellyrob99
kellyrob99 / cliGroovyshSamples.groovy
Created February 25, 2012 06:53
Samples of running Groovy scripts remotely on the Jenkins/Hudson server through the CLI
@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()
def listPlugins = 'Hudson.instance.pluginManager.plugins.each { \
@kellyrob99
kellyrob99 / gradle-dependency-analyze.gradle
Created December 19, 2012 05:00 — forked from anonymous/gradle-dependency-analyze.gradle
A simple Gradle wrapper for the maven dependency:analyze goal
import org.apache.maven.shared.dependency.analyzer.ClassAnalyzer
import org.apache.maven.shared.dependency.analyzer.DefaultClassAnalyzer
import org.apache.maven.shared.dependency.analyzer.DependencyAnalyzer
import org.apache.maven.shared.dependency.analyzer.ProjectDependencyAnalysis
import org.apache.maven.shared.dependency.analyzer.asm.ASMDependencyAnalyzer
import org.gradle.api.Project
import org.gradle.api.artifacts.ConfigurationContainer
import org.gradle.api.artifacts.ResolvedArtifact
import org.gradle.api.artifacts.ResolvedDependency
@kellyrob99
kellyrob99 / updateAllPlugins.groovy
Created February 25, 2012 06:51
Jenkins/Hudson recipe for updating all Plugins using the CLI
def findPluginsWithUpdates = '''
Hudson.instance.pluginManager.plugins.inject([]) { List toUpdate, plugin ->
if(plugin.hasUpdate())
{
toUpdate << plugin.shortName
}
toUpdate
}.inspect()
'''
OutputStream updateablePlugins = new ByteArrayOutputStream()
@kellyrob99
kellyrob99 / repoAssetLister.groovy
Last active March 15, 2022 08:44
List all assets in a given repository that have been updated after a specific time
import org.sonatype.nexus.repository.storage.Asset
import org.sonatype.nexus.repository.storage.Query
import org.sonatype.nexus.repository.storage.StorageFacet
import groovy.json.JsonOutput
import groovy.json.JsonSlurper
def request = new JsonSlurper().parseText(args)
assert request.repoName: 'repoName parameter is required'
assert request.startDate: 'startDate parameter is required, format: yyyy-mm-dd'
@kellyrob99
kellyrob99 / rawPopulator.groovy
Created September 22, 2016 16:38
Uploads all files in a given directory to a Raw hosted Repository on Nexus 3.
@Grab('org.codehaus.groovy.modules.http-builder:http-builder:0.7.2')
import groovyx.net.http.HTTPBuilder
import org.apache.http.HttpRequest
import org.apache.http.HttpRequestInterceptor
import org.apache.http.protocol.HttpContext
import static groovy.io.FileType.FILES
import static groovyx.net.http.ContentType.BINARY
import static groovyx.net.http.ContentType.TEXT
import static groovyx.net.http.Method.PUT
@kellyrob99
kellyrob99 / setupNewServer.groovy
Last active June 21, 2021 13:24
Install a suite of plugins in a locally running Jenkins/Hudson server and restart it.`
@GrabResolver(name='glassfish', root='http://maven.glassfish.org/content/groups/public/')
@GrabResolver(name='jenkins', root='http://maven.jenkins-ci.org/content/repositories/releases')
@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'
@kellyrob99
kellyrob99 / openCsv.groovy
Created December 4, 2011 18:35
OpenCSV in a groovy script to read in a file, filter the content and write out the result
@Grab(group = 'net.sf.opencsv', module = 'opencsv', version = '2.3')
import au.com.bytecode.opencsv.CSVReader
import au.com.bytecode.opencsv.CSVParser
import au.com.bytecode.opencsv.CSVWriter
def TEST_FILE_NAME = 'test.csv'
def TEST_OUTPUT_FILE_NAME = 'testOut.csv'
List<String[]> rows = new CSVReader(new FileReader(new File(TEST_FILE_NAME)), CSVParser.DEFAULT_SEPARATOR, CSVParser.DEFAULT_ESCAPE_CHARACTER, CSVParser.DEFAULT_QUOTE_CHARACTER, 1).readAll()
def rowsOver100 = rows.findAll {it[1].toInteger() > 100}
@kellyrob99
kellyrob99 / repos.groovy
Created April 23, 2012 01:25
Access the Github V3 api and find all watchers for a specified user's repositories. Generates output suitable for processing by https://gist.github.com/2475460
@Grab('org.codehaus.groovy.modules.http-builder:http-builder:0.5.2')
import groovy.json.JsonBuilder
import groovyx.net.http.HTTPBuilder
import static groovyx.net.http.ContentType.JSON
final rootUser = args[0]
final String RATE_LIMIT_HEADER = 'X-RateLimit-Remaining'
final String rootUrl = 'https://api.github.com'
final Closure<Boolean> hasWatchers = {it.watchers > 1}
final Closure findReposForUser = { HTTPBuilder http, username ->
@kellyrob99
kellyrob99 / Minimal Gradle+Geb build script
Created March 4, 2011 04:51
Gives a Gradle build with IDE and maven support, ready to go for Geb and Spock and the Firefox web driver.
apply plugin: 'groovy'
apply plugin: 'idea'
apply plugin: 'maven'
apply plugin: 'eclipse'
apply plugin: 'project-report'
version = '1.0-SNAPSHOT'
group = ''
versions = [
@kellyrob99
kellyrob99 / UpdateEnvironmentPlist.sh
Created May 26, 2016 18:40 — forked from SQiShER/UpdateEnvironmentPlist.sh
Two simple commands to resolve problems with Maven installed via Homebrew
defaults write ~/.MacOSX/environment.plist M2_HOME `brew --prefix maven`/libexec
defaults write ~/.MacOSX/environment.plist M2 `brew --prefix maven`/libexec/bin