Support building from branches other than master
diff --git a/ansible/roles/common/files/build-ci.sh b/ansible/roles/common/files/build-ci.sh
index db6993e..e54960b 100755
--- a/ansible/roles/common/files/build-ci.sh
+++ b/ansible/roles/common/files/build-ci.sh
@@ -19,10 +19,12 @@
 
 set -e
 
-# create a distribution tarball from the current git master branch
+# create a distribution tarball from the requested git branch
 cd /usr/src/couchdb-checkout
 git reset --hard
+git clean -fdx
 git pull
+git checkout $GIT_BRANCH
 ./configure --with-curl
 make dist
 
diff --git a/ansible/roles/common/tasks/couchdb.yml b/ansible/roles/common/tasks/couchdb.yml
index a16f630..a26ef04 100644
--- a/ansible/roles/common/tasks/couchdb.yml
+++ b/ansible/roles/common/tasks/couchdb.yml
@@ -39,8 +39,6 @@
     dest: /usr/src/couchdb-checkout
     accept_hostkey: yes
     force: yes
-    # which branch/tag do we actually want to build? I'd say master.
-    # version: developer-preview-2.0
 
 - name: set permissions on couchdb build
   file:
diff --git a/jenkins/build.sh b/jenkins/build.sh
index 658b8a6..00f0256 100755
--- a/jenkins/build.sh
+++ b/jenkins/build.sh
@@ -35,18 +35,18 @@
 cd "$COUCHDB_CI_DIRECTORY"
 
 DOCKER_IMAGE="couchdbdev/"
-DOCKER_OPTIONS=""
+DOCKER_OPTIONS="-e $GIT_BRANCH"
 
 case $OS in
   centos-6*)
     echo "Using CentOS 6"
     DOCKER_IMAGE=$DOCKER_IMAGE"centos-6-"
-    DOCKER_OPTIONS="-e LD_LIBRARY_PATH=/usr/local/lib"
+    DOCKER_OPTIONS="$DOCKER_OPTIONS -e LD_LIBRARY_PATH=/usr/local/lib"
     ;;
   centos-7*)
     echo "Using CentOS 7"
     DOCKER_IMAGE=$DOCKER_IMAGE"centos-7-"
-    DOCKER_OPTIONS="-e LD_LIBRARY_PATH=/usr/local/lib"
+    DOCKER_OPTIONS="$DOCKER_OPTIONS -e LD_LIBRARY_PATH=/usr/local/lib"
     ;;
   debian-8*)
     echo "Using Debian 8"
diff --git a/readme.markdown b/readme.markdown
index 5d91a20..166d485 100644
--- a/readme.markdown
+++ b/readme.markdown
@@ -31,7 +31,7 @@
 
 ## Open questions and TODOs
 * Right now we run a CouchDB build on all combinations on each commit, but perhaps we don't need to run Jenkins this often. (We also have Travis CI for a single OS and a few Erlang revisions.) Should we just build them once a day?
-* Right now we only build on the master branch. Travis CI handles PRs. ASF hasn't set up a Jenkins/Gitbox bridge yet, but if they do we can consider having Jenkins build PRs as well.
+* Right now we only trigger Jenkins on the master branch. The images support building from whatever branch $GIT_BRANCH is set to (c.f. Jenkins environment variable.) Travis CI currently handles PRs. ASF hasn't set up a Jenkins/Gitbox bridge yet, but if they do we can consider having Jenkins build PRs as well.
 * Ideally, we'd also like to build convenience packages for some of these platforms on a regular basis, i.e. nightly - especially the platforms where building the software is harder (Windows).
 * Currently, when changes occur to the base images (bugfixes, new OS/Erlang combinations added, etc.) new images are built manually using the scripts in `bin/`. TODO: automate this process in a way that avoids forcibly rebuilding every VM/Erlang combination with every checkin.