Skip to content

Instantly share code, notes, and snippets.

View cg-soft's full-sized avatar

Christian Goetze cg-soft

View GitHub Profile
#!/usr/bin/env python2.7
# Filter a set of file paths using wildcarded inclusion and exclusion rules
#
# Usage: See tests below
#
# Restrictions:
# File paths are assumed to be relative paths. Leading slashes are ignored.
# File names may not contain wildcards.
# Supported wildcards:
#!/bin/sh
rm -rf origin client
git init origin
( cd origin
echo 'A file' > file.txt
git add file.txt
git commit -m 'Initial commit' )
git clone origin client
cat > client/.git/config <<EOF
@cg-soft
cg-soft / explore.groovy
Created October 6, 2015 17:26
Discover Groovy Properties and Methods
// These two functions prove invaluable to understand and explore
// the jenkins data model. Include in a system groovy script or in
// the script console, and discover where the data really sits.
// See also http://stackoverflow.com/questions/32876496/how-can-i-retrieve-the-build-parameters-from-a-queued-job
// Credit to http://stackoverflow.com/users/172599/dave-bacher
def showProps(inst, prefix="Properties:") {
println prefix
for (prop in inst.properties) {
@cg-soft
cg-soft / scheduler.groovy
Last active June 20, 2020 03:53
Dynamic Jenkins Job Scheduler
// Schedule builds TeamCity style: Given a dependency relationship between builds,
// start all builds whose prerequisite builds have completed.
// This is intended to be run as a system groovy script in Jenkins.
// Unbound variables:
// sleepSeconds - amount of time to sleep between polls. 5-15 seconds seem good.
// Every entry in the jobToRun map is expected to have this format:
// JobId: [ JobName: <actual jenkins name of the job>,
@cg-soft
cg-soft / build.gradle
Last active August 29, 2015 14:20
Compute version string from git branch and tag info.
// This is how you use the code in your top level build.gradle
def computedVersion = new ComputedVersion()
ext.computedShortVersion = computedVersion.getVersion(rootDir.toString())
ext.computedLongVersion = computedVersion.padVersion(computedShortVersion)
ext.computedTargetBranch = computedVersion.activeBranch
def computedVersionTest() {
// printing this here allows the tracking branch behavior to be
// tested manually.