Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
git bisect for Jenkins
#!/bin/bash
# git bisect job for jenkins, originally by @bashlog
GOOD_BUILD=$(curl 'http://jenkins.example.org:8080/job/BUILDNAME/lastStableBuild/api/json' | sed 's:[{},]:\n:g'|grep '"number":'|sed 's/.*://')
BAD_BUILD=$(($GOOD_BUILD + 1))
curl -f "http://jenkins.example.org:8080/job/BUILDNAME/$BAD_BUILD/api/json" || BAD_BUILD=$(($GOOD_BUILD + 2))
curl -f "http://jenkins.example.org:8080/job/BUILDNAME/$BAD_BUILD/api/json" || BAD_BUILD=$(($GOOD_BUILD + 3))
curl -f "http://jenkins.example.org:8080/job/BUILDNAME/$BAD_BUILD/api/json" || BAD_BUILD=$(($GOOD_BUILD + 4))
curl -f "http://jenkins.example.org:8080/job/BUILDNAME/$BAD_BUILD/api/json" || BAD_BUILD=$(($GOOD_BUILD + 5))
curl -f "http://jenkins.example.org:8080/job/BUILDNAME/$BAD_BUILD/api/json" || BAD_BUILD=$(($GOOD_BUILD + 6))
GOOD_HASH=$(curl "http://jenkins.example.org:8080/job/BUILDNAME/$GOOD_BUILD/api/json" | sed 's:[{}]:\n:g'|grep '"SHA1".*name'|sed 's/"SHA1":"\([^"]*\)".*/\1/')
BAD_HASH=$(curl "http://jenkins.example.org:8080/job/BUILDNAME/$BAD_BUILD/api/json" | sed 's:[{}]:\n:g'|grep '"SHA1".*name'|sed 's/"SHA1":"\([^"]*\)".*/\1/')
CURRENT_HASH=$(git log --pretty=oneline|head -n1|sed 's: .*::')
git bisect start $BAD_HASH $GOOD_HASH
git bisect run ant autoloader phpunit-verbose compilejs
git checkout $CURRENT_HASH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.