Skip to content

Instantly share code, notes, and snippets.

View schlueter's full-sized avatar

Brandon Schlueter schlueter

  • United States of America
View GitHub Profile
@schlueter
schlueter / set_jenkins_build_description.groovy
Created November 1, 2017 18:04 — forked from louis89/set_jenkins_build_description.groovy
A Groovy script to automatically set a Jenkins build's description to the title of the pull request that triggered the build. Works with GitHub and Bitbucket.
import groovy.json.JsonSlurper
def build = Thread.currentThread().executable
def workspace = new File(build.workspace.getRemote())
def repositoryMatcher = "git config --get remote.origin.url".execute(null, workspace).text =~ /.+?(bitbucket.org|github.com)(?::|\/)(.*?).git$/
def pullIdMatcher = "git log ${build.getEnvironment()["GIT_COMMIT"]} --merges --oneline -n 1".execute(null, workspace).text =~ /pull request #(\d+)/
if (!pullIdMatcher) {
println "Could not find pull request for commit '${build.getEnvironment()["GIT_COMMIT"]}'."
# Mac OS X Lion introduced a new, iOS-like context menu when you press and hold a key
# that enables you to choose a character from a menu of options. If you are on Lion
# try it by pressing and holding down 'e' in any app that uses the default NSTextField
# for input.
#
# It's a nice feature and continues the blending of Mac OS X and iOS features. However,
# it's a nightmare to deal with in Sublime Text if you're running Vintage (Vim) mode,
# as it means you cannot press and hold h/j/k/l to move through your file. You have
# to repeatedly press the keys to navigate.