Allow running the tests with specific versions of Jenkins
diff --git a/tests/functions.bats b/tests/functions.bats
index 9847f5a..7a849eb 100644
--- a/tests/functions.bats
+++ b/tests/functions.bats
@@ -10,7 +10,7 @@
 
 @test "build image" {
   cd $BATS_TEST_DIRNAME/..
-  docker build -t $SUT_IMAGE .
+  docker_build -t $SUT_IMAGE .
 }
 
 @test "versionLT" {
diff --git a/tests/install-plugins.bats b/tests/install-plugins.bats
index b035dac..0f10eb4 100644
--- a/tests/install-plugins.bats
+++ b/tests/install-plugins.bats
@@ -8,7 +8,7 @@
 
 @test "build image" {
   cd $BATS_TEST_DIRNAME/..
-  docker build -t $SUT_IMAGE .
+  docker_build -t $SUT_IMAGE .
 }
 
 @test "plugins are installed with plugins.sh" {
diff --git a/tests/runtime.bats b/tests/runtime.bats
index e0baac1..fe6763e 100644
--- a/tests/runtime.bats
+++ b/tests/runtime.bats
@@ -9,7 +9,7 @@
 
 @test "build image" {
   cd $BATS_TEST_DIRNAME/..
-  docker build -t $SUT_IMAGE .
+  docker_build -t $SUT_IMAGE .
 }
 
 @test "clean test containers" {
diff --git a/tests/test_helpers.bash b/tests/test_helpers.bash
index ed1462c..da6d381 100644
--- a/tests/test_helpers.bash
+++ b/tests/test_helpers.bash
@@ -41,6 +41,14 @@
     false
 }
 
+function docker_build {
+    if [ -n "$JENKINS_VERSION" ]; then
+        docker build --build-arg JENKINS_VERSION=$JENKINS_VERSION --build-arg JENKINS_SHA=$JENKINS_SHA "$@"
+    else
+        docker build "$@"
+    fi
+}
+
 function get_jenkins_url {
     if [ -z "${DOCKER_HOST}" ]; then
         DOCKER_IP=localhost