Skip to content

Instantly share code, notes, and snippets.

View outofcoffee's full-sized avatar

Pete Cornish outofcoffee

View GitHub Profile
@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 / 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 / RestAssuredKotlin.md
Created July 25, 2017 20:07
DSL for using RestAssured with Kotlin

DSL for using RestAssured with Kotlin

Example

        given {
            on {
                get("/orders/123") itHas {
                    statusCode(404)
                }
@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 / gradle-kotlin-publish-s3-maven-repo.gradle
Last active March 4, 2019 11:40
Publish a Kotlin module to an S3 Maven repository, using Gradle.
/*
* Publish a Kotlin module to an S3 Maven repository, using Gradle.
* This assumes that the AWS/IAM credentials have 'bucket list' as well as 'object put' and 'object get' permissions.
*/
ext.version_kotlin = '1.0.5-2'
buildscript {
repositories {
mavenCentral()
@outofcoffee
outofcoffee / get_s3_file.sh
Created August 28, 2017 12:34 — forked from davidejones/get_s3_file.sh
curl get file from private s3 with iam role
#!/bin/bash
instance_profile=`curl http://169.254.169.254/latest/meta-data/iam/security-credentials/`
aws_access_key_id=`curl http://169.254.169.254/latest/meta-data/iam/security-credentials/${instance_profile} | grep AccessKeyId | cut -d':' -f2 | sed 's/[^0-9A-Z]*//g'`
aws_secret_access_key=`curl http://169.254.169.254/latest/meta-data/iam/security-credentials/${instance_profile} | grep SecretAccessKey | cut -d':' -f2 | sed 's/[^0-9A-Za-z/+=]*//g'`
token=`curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/${instance_profile} | sed -n '/Token/{p;}' | cut -f4 -d'"'`
file="somefile.deb"
bucket="some-bucket-of-mine"
date="`date +'%a, %d %b %Y %H:%M:%S %z'`"
@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.