Skip to content

Instantly share code, notes, and snippets.

View daxroc's full-sized avatar

Damien Roche daxroc

  • Wexford, Ireland
View GitHub Profile
class MyRunnable implements Runnable {
// Create class properties we can set
private String message;
// Create Constructor - can customise
// what's set when we create a new instance
public MyRunnable(String message) {
// Set class properties y
// when we create the a new instance of the class
@daxroc
daxroc / delete-idle-nodes.groovy
Created May 30, 2018 12:06
Jenkins - Deletes nodes that are idle with matching prefix
String agentList = ""
String agentPrefix = "Ubuntu"
Integer total = 0
Integer oftype = 0
Integer deleted = 0
// Go through nodes and build a list of agents matching the supplied online/offline booleans
Jenkins.instance.nodes.each {
//println "Checking agent: $it.nodeName"
if (it.nodeName.contains(agentPrefix)){
@daxroc
daxroc / delete-nodes.groovy
Last active May 30, 2018 12:13
Delete jenkins agent node/computers that have retried 5 times
String agentList = ""
String agentPrefix = "example"
Integer agentTotal = 0
Integer ofType = 0
Integer ofDeleted = 0
// Go through nodes and build a list of agents matching the supplied online/offline booleans
Jenkins.instance.nodes.each {
//println "Checking agent: $it.nodeName"
if (it.nodeName.contains(agentPrefix)){
@daxroc
daxroc / Dockerfile
Created January 31, 2018 14:21
Create a Docker jenkins-agent with custom toolchain
FROM jenkinsci/jnlp-slave
USER root
RUN apt-get update && apt-get install whatever
USER jenkins
ENTRYPOINT ["jenkins-slave"]
@daxroc
daxroc / DeploymentAgent.groovy
Last active January 20, 2020 10:03
Jenkins Pipeline Unit testing shared library
package com.example.jenkins.agents
void example(){
echo "example running"
}
return this
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.define "workstation" do |ws|
ws.vm.hostname = "workstation"
ws.vm.network "private_network", type: "dhcp", virtualbox__intnet: "lab"
import org.yaml.snakeyaml.Yaml
Yaml yaml = new Yaml()
def plugins = Jenkins.instance.pluginManager.plugins
def output = []
def dependencies = []
plugins.each { p ->
// println p.getProperties().toString()
def name = p.shortName
def version = p.version
import org.jenkinsci.plugins.saml.*
def sr = Jenkins.getInstance().getSecurityRealm()
println sr.loadUserByUsername("keyser.soze")
println sr.dump()
@daxroc
daxroc / env2.py
Last active September 5, 2017 15:43
AWS CLI Helper for switching shell variables on multiple profiles
#!/usr/bin/env python
import os
import json
import argparse
from pprint import pprint
from ConfigParser import SafeConfigParser
HOME = os.environ['HOME']
PROFILE = os.environ['AWS_DEFAULT_PROFILE']
@daxroc
daxroc / gist:c3cb760f23aa6e0025e43307a77b852f
Created June 2, 2017 21:42
Terraform Example ephemeral disk definition for ec2 instance
ephemeral_block_device {
device_name = "xvdb"
virtual_name = "ephemeral0"
}