Skip to content

Instantly share code, notes, and snippets.

View willis7's full-sized avatar
🏠
Working from home

Sion Williams willis7

🏠
Working from home
View GitHub Profile
@willis7
willis7 / configure_clouds.groovy
Last active July 10, 2018 15:56
Programatically add templates and clouds to Jenkins via Docker plugin
import com.nirima.jenkins.plugins.docker.DockerCloud
import com.nirima.jenkins.plugins.docker.DockerTemplate
import com.nirima.jenkins.plugins.docker.DockerTemplateBase
import com.nirima.jenkins.plugins.docker.launcher.AttachedDockerComputerLauncher
import io.jenkins.docker.connector.DockerComputerAttachConnector
//
// TEMPLATES
def tmplConf = '''
@willis7
willis7 / dockerPlugin.groovy
Created July 4, 2018 13:36
Configure Docker plugin via Groovy script
import com.nirima.jenkins.plugins.docker.DockerCloud
import com.nirima.jenkins.plugins.docker.DockerTemplate
import com.nirima.jenkins.plugins.docker.DockerTemplateBase
import com.nirima.jenkins.plugins.docker.launcher.AttachedDockerComputerLauncher
import io.jenkins.docker.connector.DockerComputerAttachConnector
import jenkins.model.Jenkins
// parameters
def dockerTemplateBaseParameters = [
bindAllPorts: false,
@willis7
willis7 / can_reach.sh
Created July 4, 2018 06:39
“check that we can connect to a remote server on a particular port” Excerpt From: Lorin Hochstein. “Ansible.”
#!/bin/bash
#
# Usage:
# $ “can_reach.sh www.example.com 80 1”
host=$1
port=$2
timeout=$3
nc -z -w $timeout $host $port”
@willis7
willis7 / executors.groovy
Created June 20, 2018 10:54
Groovy script to manipulate Jenkins config.xml and set the number of executors to 0
import jenkins.model.*
Jenkins.instance.setNumExecutors(0)
import jenkins.*
import jenkins.model.*
import hudson.*
import hudson.model.*
import com.nirima.jenkins.plugins.docker.*
import hudson.plugins.sshslaves.SSHConnector
import com.nirima.jenkins.plugins.docker.launcher.*
import com.nirima.jenkins.plugins.docker.strategy.*
@willis7
willis7 / shellcheck.Makefile
Last active June 8, 2018 11:21
Running shellcheck using make
#!/usr/bin/make
# exclude switches are useful for git and vim users. Other may apply here.
test: shellcheck.check
grep -rIl '^#![[:blank:]]*/bin/\(bash\|sh\|zsh\)' \
--exclude-dir=.git --exclude=*.sw? \
| xargs shellcheck
# .check targets just tests for a command to be available on your PATH.
.PHONY: %.check
@willis7
willis7 / newScala.sh
Created May 23, 2018 06:54
creates the directory structure for a scala project
#!/bin/sh
mkdir -p src/{main,test}/{java,resources,scala}
mkdir lib project target
# create an initial build.sbt file
echo 'name := "MyProject"
version := "1.0"
scalaVersion := "2.10.0"' > build.sbt
==> router: Running provisioner: file...
The guest operating system of the machine could not be detected!
Vagrant requires this knowledge to perform specific tasks such
as mounting shared folders and configuring networks. Please add
the ability to detect this guest operating system to Vagrant
by creating a plugin or reporting a bug.

Keybase proof

I hereby claim:

  • I am willis7 on github.
  • I am willis7 (https://keybase.io/willis7) on keybase.
  • I have a public key ASBDtl8NJod40Ti6FT558HT0AoHPVd0_JkRcZD846bBeEgo

To claim this, I am signing this object:

@willis7
willis7 / cmd-cheat-sheet.md
Created July 6, 2017 18:48
Command-line Keyboard Shortcuts
  • Alt + click -- position the cursor in the terminal
  • Ctrl + a -- go to the start of a line
  • Ctrl + e -- go to the end of a line
  • Ctrl + u -- delete from cursor to the start of the line
  • Ctrl + k -- delete from cursor to the end of the line
  • Ctrl + w -- delete from cursor to the start of a word