Skip to content

Instantly share code, notes, and snippets.

View outofcoffee's full-sized avatar

Pete Cornish outofcoffee

View GitHub Profile
outofcoffee / setup-users.groovy
Created July 26, 2020 15:29 — forked from johnbuhay/setup-users.groovy
jenkins init.groovy.d script for configuring users
View setup-users.groovy
import jenkins.*
import hudson.*
import com.cloudbees.plugins.credentials.*
import com.cloudbees.plugins.credentials.common.*
import com.cloudbees.jenkins.plugins.sshcredentials.impl.*
import hudson.plugins.sshslaves.*;
import hudson.model.*
import jenkins.model.*
outofcoffee / baseURL.groovy
Created July 26, 2020 15:15 — forked from fishi0x01/baseURL.groovy
This is a collection of groovy scripts I gathered and use for bootstrapping Jenkins. Most of this can also be achieved with the CasC Plugin
View baseURL.groovy
* This script configures the Jenkins base URL.
import jenkins.model.JenkinsLocationConfiguration
JenkinsLocationConfiguration location = Jenkins.instance.getExtensionList('jenkins.model.JenkinsLocationConfiguration')[0]
location.url = ''
outofcoffee /
Last active December 19, 2019 19:23
Disk usage by top level directory
du / --max-depth 1 2>&1 | grep -v cannot | sort -Vr -k1,1 | head -n20
outofcoffee /
Created November 22, 2018 19:58
Set up Docker and Docker Compose on Raspberry Pi

Set up Docker and Docker Compose on Raspberry Pi


Use the convenience script approach

curl -fsSL -o sudo sh

Now run docker -v to verify it works.

outofcoffee / migrateTerraformResources.groovy
Created November 13, 2018 01:28
Migrates Terraform resources between modules.
View migrateTerraformResources.groovy
#!/usr/bin/env groovy
import groovy.json.JsonSlurper
// Migrates Terraform resources between modules.
// Resources are read from the source Terraform module, imported into the target module,
// then removed from the source module. The resource names can differ between source and target
// modules.
// Configure the source and target mappings in a JSON file, e.g.
outofcoffee /
Created September 18, 2018 12:51 — forked from lehnerpat/
GitHub Compare view

GitHub's compare view is available at:$USER/$REPO/compare/$REV_A...$REV_B

Naturally, $USER and $REPO are the owner (user/organization) and repository names, respectively.

$REV{A,B} are the two sides of the compare view; they can either be a ref in $USER's repository, i.e. the name of a branch, tag or a commit SHA, or it can be a ref in $OWNER's fork of the repository by using the format $OWNER:$REF.

You can get a diff or patch for the result of the compare view by appending .diff or .patch to the URL, respectively.

outofcoffee /
Last active November 21, 2023 14:04
Check if Docker image exists with tag in AWS ECR
#!/usr/bin/env bash
# Example:
# ./ foo/bar mytag
if [[ $# -lt 2 ]]; then
echo "Usage: $( basename $0 ) <repository-name> <image-tag>"
exit 1
IMAGE_META="$( aws ecr describe-images --repository-name=$1 --image-ids=imageTag=$2 2> /dev/null )"
outofcoffee /
Created January 3, 2018 01:05 — forked from kevin-smets/
Local Kubernetes setup on macOS with minikube on VirtualBox and local Docker registry


Minikube requires that VT-x/AMD-v virtualization is enabled in BIOS. To check that this is enabled on OSX / macOS run:

sysctl -a | grep machdep.cpu.features | grep VMX

If there's output, you're good!



How to setup AWS lambda function to talk to the internet and VPC

I'm going to walk you through the steps for setting up a AWS Lambda to talk to the internet and a VPC. Let's dive in.

So it might be really unintuitive at first but lambda functions have three states.

  1. No VPC, where it can talk openly to the web, but can't talk to any of your AWS services.
  2. VPC, the default setting where the lambda function can talk to your AWS services but can't talk to the web.
  3. VPC with NAT, The best of both worlds, AWS services and web.
outofcoffee / system-config.yml
Created October 2, 2017 18:06
Sample Corebot system configuration.
View system-config.yml
# System configuration
version: '1'
driver: jenkins
showJobOutput: false
showJobOutcome: true
runAsTriggerUser: false