Skip to content

Instantly share code, notes, and snippets.

Jenkins.instance.getItemByFullName("group/pipeline")
.getBuildByNumber(8094)
.finish(hudson.model.Result.ABORTED, new java.io.IOException("Aborting build"));
@ipleten
ipleten / Jenkinsfile
Created September 29, 2021 22:08
Set labels on Jenkins steps.
import org.jenkinsci.plugins.workflow.actions.LabelAction;
import org.jenkinsci.plugins.workflow.cps.CpsThread;
pipeline {
agent any
stages {
stage('Hello') {
steps {
script {
"\U$(printf '%3x' 128$(date +%u)$(( $RANDOM % 99 )) )"
cat json.flie | jq 'path(..) | [.[] | tostring ] | join("/") '
function _cache() {
HASH=$(echo $@ | md5 )
CACHE_FILE="/tmp/${HASH}"
NOW=$(date +%s)
if [[ ! -e $CACHE_FILE ]] || [[ $(($(date +%s)-$(date -r $CACHE_FILE +%s))) -ge 3600 ]]; then
RESULT=$(eval "$@")
echo "$RESULT" > /tmp/$HASH
echo "$RESULT"
else
cat $CACHE_FILE
@ipleten
ipleten / Makefile
Created March 26, 2020 23:28
Replace clean: section in Makefile assuming sections are separated by empty line. Sed multi-line replacement.
section:
ls
clean:
rm -rf ./tagget
something-else:
kill-all-human.sh
kubectl get pods -o json | jq -r '.items[] | select(.status.conditions[] | select(.type == "Ready" and .status == "True") )| .metadata.name'
@ipleten
ipleten / [bash] run_retry
Last active July 18, 2019 22:51
Bash retry function with delays.
#!/bin/bash
# helper funciton for retry NUM_TRIES times with SLEEP_TIME delays between each
function run_retry {
local SLEEP_TIME=$1
local NUM_TRIES=$2
shift 2
local CMD=$*
COUNT=0
echo "Running '$CMD'"
#!/bin/bash
set -e
env='prod'
team='common'
svc='adm'
declare -A IDS
IDS=(
# prod
@ipleten
ipleten / .vimrc
Created July 4, 2017 14:32
.vimrc
set nocompatible
set number
set ruler
syntax on
" Set encoding
set encoding=utf-8
" Whitespace stuff