Skip to content

Instantly share code, notes, and snippets.

@tknerr
tknerr / chefdk-install.log
Last active August 17, 2017 19:32
ChefDK doesn't install on Win 10 1703 - log output of `msiexec /i chefdk-windows-1.5.0.msi /l*V chefdk-install.log`
=== Verbose logging started: 8/18/2017 4:19:49 Build type: SHIP UNICODE 5.00.10011.00 Calling process: C:\Windows\system32\msiexec.exe ===
MSI (c) (D8:A0) [04:19:49:117]: Font created. Charset: Req=0, Ret=0, Font: Req=MS Shell Dlg, Ret=MS Shell Dlg
MSI (c) (D8:A0) [04:19:49:117]: Font created. Charset: Req=0, Ret=0, Font: Req=MS Shell Dlg, Ret=MS Shell Dlg
MSI (c) (D8:B4) [04:19:49:180]: Resetting cached policy values
MSI (c) (D8:B4) [04:19:49:180]: Machine policy value 'Debug' is 0
MSI (c) (D8:B4) [04:19:49:180]: ******* RunEngine:
******* Product: chefdk-windows-1.5.0.msi
******* Action:
@tknerr
tknerr / get-plugins.sh
Created July 17, 2017 16:22
Get Jenkins Plugins + Versions via Jenkins XML API (and convert to copy/pasteable YAML format for Ansible ;-))
curl 'http://admin:admin@localhost:8080/pluginManager/api/xml?depth=1&xpath=/*/*/shortName|/*/*/version&wrapper=plugins' \
| perl -pe 's/.*?<shortName>([\w-]+).*?<version>([^<]+)()(<\/\w+>)+/- { name: \1, version: \2 }\n/g' \
| sort
@tknerr
tknerr / Jenkinsfile
Last active February 27, 2017 08:17
Trying to run steps on many slaves in parallel, but when the `doStuff(x)` closure is executed the slave name argument being passed (`x`) is always "slave3"
def onEachSlave(doStuff) {
def doStuffClosures = [:]
for (slave in ['slavelnx1', 'slavelnx2', 'slavelnx3']) {
def s = slave
doStuffClosures[s] = { echo "running on ${s}..."; doStuff(s); echo "...done on ${s}!" }
}
return doStuffClosures
}
parallel(onEachSlave { slave ->
echo "doing stuff on ${slave}..."

I was trying to get more meaningful stack traces, but it seems that the exception we catch does not carry any more specific details about the step that failed. The only info we get is that the pipeline step failed and the exit code it failed with.

Example pipeline code snippet:

node {
    try {
        stage('do-stuff') {
            sh "echo do somehing; exit 0"
        }
@tknerr
tknerr / preapprove.groovy
Created January 31, 2017 09:15
pre-approve all pending script approvals, e.g. from a JobDSL script
import jenkins.*
import jenkins.model.*
Jenkins.instance.getExtensionList('org.jenkinsci.plugins.scriptsecurity.scripts.ScriptApproval')[0].get().preapproveAll()
@tknerr
tknerr / abstract.md
Created January 20, 2017 16:49
Karlsruher Entwicklertag 2017

Title

Abstract

Author Bio

@tknerr
tknerr / pedantically_commented_playbook.yml
Created October 25, 2016 14:21 — forked from marktheunissen/pedantically_commented_playbook.yml
Insanely complete Ansible playbook, showing off all the options
---
# ^^^ YAML documents must begin with the document separator "---"
#
#### Example docblock, I like to put a descriptive comment at the top of my
#### playbooks.
#
# Overview: Playbook to bootstrap a new host for configuration management.
# Applies to: production
# Description:
# Ensures that a host is configured for management with Ansible.
@tknerr
tknerr / list-jenkins-plugins.sh
Created October 19, 2016 22:02
List the installed jenkins plugins @ version
#!/bin/sh
curl 'http://localhost:8080/pluginManager/api/xml?depth=1&xpath=/*/*/shortName|/*/*/version&wrapper=plugins' | perl -pe 's/.*?<shortName>([\w-]+).*?<version>([^<]+)()(<\/\w+>)+/\1@\2\n/g' | sort
@tknerr
tknerr / x.sh
Created June 14, 2016 05:42
show the total count and list the first 10 files per day, archive all of them
# show the total count and list the first 10 files per day
for i in `seq 1 100`; do files=$(find . -daystart -mtime $i); num=$(echo $files | wc -w); date=$(date -d "-$i day" +%Y-%m-%d); if [ $num -gt 0 ]; then echo "$num files found for $date"; echo $files | tr ' ' '\n' | xargs ls -l | head -n 10; fi; done
# also archive...
for i in `seq 1 100`; do files=$(find /var/log/ccu/noise-test -daystart -mtime $i -name "TM-Noise*.csv.*.gz"); num=$(echo $files | wc -w); date=$(date -d "-$i day" +%Y-%m-%d); if [ $num -gt 0 ]; then echo "$num files found for $date"; echo $files | tr ' ' '\n' | xargs ls -l | head -n 10; tar -czf /tmp/TM-NoiseTest-$date.tgz $files; fi; done
# long
for i in `seq 1 100`; do
@tknerr
tknerr / git-remote-symlink
Created June 10, 2016 08:15
Git remote helper to allow for `git clone symlink:///path/to/original/repo` which simply creates a symlink to the original repo