Skip to content

Instantly share code, notes, and snippets.

@tszpinda
tszpinda / plugin-list-jenkins.groovy
Created November 30, 2016 21:21
list of plugins in jenkins
Jenkins.instance.pluginManager.plugins.sort{ it ->
println "$it.shortName:latest"
}
@tszpinda
tszpinda / demo.csv
Created October 13, 2016 12:18
Test data
We can make this file beautiful and searchable if this error is corrected: It looks like row 8 should actually have 18 columns, instead of 15 in line 7.
policyID,statecode,county,eq_site_limit,hu_site_limit,fl_site_limit,fr_site_limit,tiv_2011,tiv_2012,eq_site_deductible,hu_site_deductible,fl_site_deductible,fr_site_deductible,point_latitude,point_longitude,line,construction,point_granularity
119736,FL,CLAY COUNTY,498960,498960,498960,498960,498960,792148.9,0,9979.2,0,0,30.102261,-81.711777,Residential,Masonry,1
448094,FL,CLAY COUNTY,1322376.3,1322376.3,1322376.3,1322376.3,1322376.3,1438163.57,0,0,0,0,30.063936,-81.707664,Residential,Masonry,3
206893,FL,CLAY COUNTY,190724.4,190724.4,190724.4,190724.4,190724.4,192476.78,0,0,0,0,30.089579,-81.700455,Residential,Wood,1
333743,FL,CLAY COUNTY,0,79520.76,0,0,79520.76,86854.48,0,0,0,0,30.063236,-81.707703,Residential,Wood,3
172534,FL,CLAY COUNTY,0,254281.5,0,254281.5,254281.5,246144.49,0,0,0,0,30.060614,-81.702675,Residential,Wood,1
785275,FL,CLAY COUNTY,0,515035.62,0,0,515035.62,884419.17,0,0,0,0,30.063236,-81.707703,Residential,Masonry,3
995932,FL,CLAY COUNTY,0,19260000,0,0,19260000,20610000,0,0,0,0,30.102226,-81.
@tszpinda
tszpinda / ansible-regex.yml
Created October 7, 2016 14:01
ansible local regex
---
- hosts: localhost
connection: local
gather_facts: False
tasks:
- set_fact:
ip: "192.172.32.30"
- set_fact:
x: "{{ip| regex_replace('^(\\d{1,3}\\.\\d{1,3}).*', '\\1') }}"
- debug: var=x
@tszpinda
tszpinda / updateVersion.groovy
Created August 5, 2016 14:01
update maven dep with groovy
#!/usr/bin/env groovy
import groovy.xml.*;
if (args.size() != 3 && args.size() != 4) {
println "usage: updateVersion <groupId> <artifactId> <version> [<newVersion>]"
println "newVersion - is optional if not given will only print current versions"
System.exit(1);
}
@tszpinda
tszpinda / ansible
Created August 4, 2016 14:09
ansible bits
ansible web -i hosts -m lineinfile -a 'dest='~/.bashrc' regexp='^' line="alias l=\"ls -l\"" state=present'
ansible web -i hosts -m shell -a 'ps auwx|egrep tomcat|egrep -v egrep'|egrep FAIL || echo '[PASS]'
version=10233
ansible webapps -i hosts -m shell -a "curl localhost:8080/who.jsp|egrep $version"|egrep FAIL || echo '[PASS]'
@tszpinda
tszpinda / jenkins-cleanup-workspace.groovy
Created August 4, 2016 12:19
Delete unused workspace folders from slaves
import hudson.FilePath
import jenkins.model.Jenkins
import hudson.model.Job
//
// cleans up workspace folders on slaves - removes deleted projects
//
def deleteUnusedWorkspace(FilePath root, String path) {
if(!root.list())return;
root.list().sort{child->child.name}.each { child ->
@tszpinda
tszpinda / nexus-remove-artifact.groovy
Created January 7, 2016 07:57
Nexus remove artifacts by version
def v = 30007..30017
v.each { version ->
def xml = "http://<ip>:<port>/nexus-2.1.2/service/local/data_index?v=${version}";
def baseUrl = "http://<ip>:<port>/nexus-2.1.2/content/repositories/libs-releases-local";
def parser = new XmlSlurper();
parser.setFeature('http://apache.org/xml/features/disallow-doctype-decl', true);
def root = parser.parse(xml);
root.data.artifact.each{
@tszpinda
tszpinda / http-server-folder.sh
Created January 6, 2016 12:34
Server current folder via http
python -m SimpleHTTPServer 8099
import jenkins.*
import jenkins.model.*
import hudson.*
import hudson.model.*
def jobNameStartsWith = 'EPC-1426'
def textToMatch = "Flakes"
Jenkins.instance.items.findAll { it.displayName.startsWith(jobNameStartsWith) }
.each { job ->
@tszpinda
tszpinda / jenkins-count-text-in-console.groovy
Last active January 6, 2016 09:36
jenkins count text in console
def jobNameStartsWith = 'EPC-1426-single-version'
def textToMatch = "Total time"
Jenkins.instance.items.findAll { it.displayName.startsWith(jobNameStartsWith) }
.each { job ->
if(job.builds) {
def build = job.isBuilding() ? job.builds[1] : job.builds[0]
def log = build.logFile.text
def regexPattern = "(?i).*${textToMatch}.*"
def summary = log =~ /${regexPattern}/