Skip to content

Instantly share code, notes, and snippets.

View djfdyuruiry's full-sized avatar

matthew snoddy djfdyuruiry

View GitHub Profile
@djfdyuruiry
djfdyuruiry / getTempPath.lua
Last active April 19, 2021 13:54
Simple lua module to get the path to the temporary directory on the current host (e.g. '/tmp') [https://ideone.com/675UZR]
local function getTempPath()
local directorySeperator = package.config:match("([^\n]*)\n?")
local exampleTempFilePath = os.tmpname()
-- remove generated temp file
pcall(os.remove, exampleTempFilePath)
local seperatorIdx = exampleTempFilePath:reverse():find(directorySeperator)
local tempPathStringLength = #exampleTempFilePath - seperatorIdx
@djfdyuruiry
djfdyuruiry / exec_wsl_cmd.bat
Last active January 6, 2018 17:04
Loads Bash on Ubuntu on Windows, sets bash pwd to the Windows dir where the bat script currently is, and executes a command specified by first parameter.
C:\Windows\System32\bash.exe -c "echo '%~dp0' | sed -e 's|\\\\|/|g' -e 's|^\([A-Za-z]\)\:/\(.*\)|/mnt/\L\1\E/\2|' | cd && %1"
@djfdyuruiry
djfdyuruiry / multi_brach_dsl_with_custom_strategy_and_script_path.groovy
Last active November 24, 2021 04:47
Jenkins Job DSL for a Multi-Branch Pipeline that includes Branch Source Strategy & custom Jenkinsfile script path
// A new UUID must be generated for the first run and re-used for your Job DSL, the plugin updates jobs based on ID
UUID uuid = UUID.fromString("dd847135-8391-4f66-a54c-7f8781dc3119") // generate one @ https://www.uuidgenerator.net
multibranchPipelineJob("my_awesome_job") {
displayName "my awesome job"
description "multi-branch pipeline job thingy"
configure {
it / sources / 'data' / 'jenkins.branch.BranchSource' << {
source(class: 'jenkins.plugins.git.GitSCMSource') {
id(uuid)
@djfdyuruiry
djfdyuruiry / pipeline_build_on_merge_to_master.groovy
Last active February 18, 2018 01:41
Jenkins pipeline that builds on merge to master; useful for Multi-Branch Pipelines where you only want master code to be auto built (feature branches are then manually triggered during development).
if (env.BRANCH_NAME == "master") {
properties([
pipelineTriggers([
pollSCM("H/5 * * * *")
])
])
}
pipeline {
agent none

A custom step for Jenkins pipelines that allows scaling a task n times in parallel, specifying parameters for each thread

@djfdyuruiry
djfdyuruiry / jenkinsApiClient.sh
Last active July 13, 2018 21:15
Jenkins API Client written in Bash
#!/usr/bin/env bash
########################################################################################################################
# #
# Jenkins API client written in Bash using the `wget` and `curl` commands #
# ----------------------------------------------------------------------- #
# See: https://gist.github.com/djfdyuruiry/71714479b3a5f7eb1e714df5d3499665 #
# #
# Using global configuration: #
# #
# export JENKINS_URL="https://my-
@djfdyuruiry
djfdyuruiry / gitlabApiClient.sh
Last active May 19, 2022 20:23
GitLab API Client Written in Bash
#!/usr/bin/env bash
########################################################################################################################
# #
# GitLab API client written in Bash using the `curl` command #
# ----------------------------------------------------------- #
# See: https://gist.github.com/djfdyuruiry/9eecf631e3b43fce2a4393d23e03c1ce #
# #
# Using global configuration: #
# #
# export GITLAB_URL="https://my-g
@djfdyuruiry
djfdyuruiry / watchSqs.sh
Last active May 24, 2018 13:26
Pop off and log SQS messages from a given queue, both to std out and a log file (with an err log file)
#!/bin/bash
queueName="sns-queue"
endpointUrl="http://localhost:4576"
queueUrl="${endpointUrl}/queue/${queueName}"
queueLogFile="sqs_${queueName}.log"
queueErrorLogFile="sqs_${queueName}_err.log"
jsonLoadFromStdIn="json.load(sys.stdin)"
doJsonOperation() {
@djfdyuruiry
djfdyuruiry / vagrant-utils.sh
Created June 17, 2018 16:25
Bash function 'library' which contains handy vagrant utils, including provisioning, suspending and resuming multiple machines in parallel.
#!/usr/bin/env bash
if [ ! `command -v "vagrant"` ]; then
>&2 echo "ERROR: Script $0 requires vagrant, it was not found in the path"
exit 1
fi
vagrantProvider=${VAGRANT_PROVIDER:-virtualbox}
providerAwkString="[${vagrantProvider:0:1}]${vagrantProvider:1}"
vagrant-status() {
@djfdyuruiry
djfdyuruiry / json-path-query.sh
Last active June 21, 2018 22:43
JSON path bash util function using python, supports array queries, array indices, list object fields and array length query.
#!/usr/bin/env bash
jsonLoadFromStdIn="json.load(sys.stdin)"
loopOverItems=false
loopJsonOperation=""
__doJsonOperation() {
json="$1"
operation="$2"
operationWithJsonLoad=${operation/__JSON__/$jsonLoadFromStdIn}