Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View outofcoffee's full-sized avatar

Pete Cornish outofcoffee

View GitHub Profile
@outofcoffee
outofcoffee / setup-users.groovy
Created July 26, 2020 15:29 — forked from johnbuhay/setup-users.groovy
jenkins init.groovy.d script for configuring users
import jenkins.*
import hudson.*
import com.cloudbees.plugins.credentials.*
import com.cloudbees.plugins.credentials.common.*
import com.cloudbees.plugins.credentials.domains.*
import com.cloudbees.jenkins.plugins.sshcredentials.impl.*
import hudson.plugins.sshslaves.*;
import hudson.model.*
import jenkins.model.*
import hudson.security.*
@outofcoffee
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 https://github.com/jenkinsci/configuration-as-code-plugin
#!groovy
/*
* This script configures the Jenkins base URL.
*/
import jenkins.model.JenkinsLocationConfiguration
JenkinsLocationConfiguration location = Jenkins.instance.getExtensionList('jenkins.model.JenkinsLocationConfiguration')[0]
location.url = 'https://jenkins-as-code-poc.devtail.io/'
@outofcoffee
outofcoffee / disk-usage.sh
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
outofcoffee / pi-docker.md
Created November 22, 2018 19:58
Set up Docker and Docker Compose on Raspberry Pi

Set up Docker and Docker Compose on Raspberry Pi

Docker

Use the convenience script approach

curl -fsSL https://get.docker.com -o get-docker.sh sudo sh get-docker.sh

Now run docker -v to verify it works.

@outofcoffee
outofcoffee / migrateTerraformResources.groovy
Created November 13, 2018 01:28
Migrates Terraform resources between modules.
#!/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
outofcoffee / gh-compare.md
Created September 18, 2018 12:51 — forked from lehnerpat/gh-compare.md
GitHub Compare view

GitHub's compare view is available at:

https://github.com/$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
outofcoffee / find-ecr-image.sh
Last active March 1, 2024 13:35
Check if Docker image exists with tag in AWS ECR
#!/usr/bin/env bash
# Example:
# ./find-ecr-image.sh foo/bar mytag
if [[ $# -lt 2 ]]; then
echo "Usage: $( basename $0 ) <repository-name> <image-tag>"
exit 1
fi
IMAGE_META="$( aws ecr describe-images --repository-name=$1 --image-ids=imageTag=$2 2> /dev/null )"
@outofcoffee
outofcoffee / 1_kubernetes_on_macOS.md
Created January 3, 2018 01:05 — forked from kevin-smets/1_kubernetes_on_macOS.md
Local Kubernetes setup on macOS with minikube on VirtualBox and local Docker registry

Requirements

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!

Prerequisites

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
outofcoffee / system-config.yml
Created October 2, 2017 18:06
Sample Corebot system configuration.
# System configuration
---
version: '1'
system:
defaults:
driver: jenkins
showJobOutput: false
showJobOutcome: true
runAsTriggerUser: false