diff --git a/README.md b/README.md
index f692bcd058403b942bf4cd2abaaa5b832818559b..46b5705043ad4250d96c2c2be97d3133a5c9d8ca 100644
--- a/README.md
+++ b/README.md
@@ -48,6 +48,14 @@ env.CTESTOPTS="-j1"
 env.RUN_FROM_SUBDIR="examples"
 ```
 
+- Set extra environment variables:
+The variables are gives as space separated lists of key=values pairs. The pairs must not have spaces. JOB_VARIABLES are applied to build and tests (incl. analysis), while TEST_VARIABLES are only in tests and analysis.
+```
+env.JOB_VARIABLES="A=aha B=bubu"
+env.TEST_VARABLES="PATH=${PATH}:/some/path/for/the/test"
+```
+
+
 ## Analysis jobs
 - Exclude tests from being run in valgrind (currently only possible with a single test):
 ```
diff --git a/scripts/login_docker.sh b/scripts/login_docker.sh
index 59391615d707cb4aa95fc392345ef5b99f35479d..4f55a901ce411f883c9b729c1f6f7cdd58b899c0 100755
--- a/scripts/login_docker.sh
+++ b/scripts/login_docker.sh
@@ -15,7 +15,7 @@ buildType=$3
 buildNumber=$4
 
 # should be the same as in the pipeline script (excluding the -u 0)
-DOCKER_PARAMS="--device=/dev/mtcadummys0 --device=/dev/mtcadummys1 --device=/dev/mtcadummys2 --device=/dev/mtcadummys3 --device=/dev/llrfdummys4 --device=/dev/noioctldummys5 --device=/dev/pcieunidummys6 -v /var/run/lock/mtcadummy:/var/run/lock/mtcadummy"
+DOCKER_PARAMS="--device=/dev/mtcadummys0 --device=/dev/mtcadummys1 --device=/dev/mtcadummys2 --device=/dev/mtcadummys3 --device=/dev/llrfdummys4 --device=/dev/noioctldummys5 --device=/dev/pcieunidummys6 -v /var/run/lock/mtcadummy:/var/run/lock/mtcadummy -v /opt/matlab_R2016b:/opt/matlab_R2016b"
 
 # create and start container (use options to allow gdb inside!)
 ID=`docker create --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -i ${DOCKER_PARAMS} -v /home/msk_jenkins:/home/msk_jenkins builder:${label}`
diff --git a/vars/buildTestDeploy.groovy b/vars/buildTestDeploy.groovy
index c5024a1e4c42ac1e8c95a95852ba663260dc5844..6d31e5c8c962103799b6068d22dbf4ac285ff71f 100644
--- a/vars/buildTestDeploy.groovy
+++ b/vars/buildTestDeploy.groovy
@@ -111,7 +111,7 @@ def transformIntoStep(ArrayList<String> dependencyList, String buildName, String
     stage(buildName) {
       node('Docker') {
         // we need root access inside the container and access to the dummy pcie devices of the host
-        def dockerArgs = "-u 0 --privileged --device=/dev/mtcadummys0 --device=/dev/mtcadummys1 --device=/dev/mtcadummys2 --device=/dev/mtcadummys3 --device=/dev/llrfdummys4 --device=/dev/noioctldummys5 --device=/dev/pcieunidummys6 -v /var/run/lock/mtcadummy:/var/run/lock/mtcadummy"
+        def dockerArgs = "-u 0 --privileged --device=/dev/mtcadummys0 --device=/dev/mtcadummys1 --device=/dev/mtcadummys2 --device=/dev/mtcadummys3 --device=/dev/llrfdummys4 --device=/dev/noioctldummys5 --device=/dev/pcieunidummys6 -v /var/run/lock/mtcadummy:/var/run/lock/mtcadummy -v /opt/matlab_R2016b:/opt/matlab_R2016b"
         docker.image("builder:${label}").inside(dockerArgs) {
           script {
             helper.doBuildTestDeploy(dependencyList, label, buildType, gitUrl)
diff --git a/vars/helper.groovy b/vars/helper.groovy
index 182829bd0e1077974af3fdb94a9eb0fac680fa97..0871440d480593423846bd85e41a3c7de8623bcc 100644
--- a/vars/helper.groovy
+++ b/vars/helper.groovy
@@ -166,6 +166,9 @@ def doBuild(String label, String buildType) {
      else
       SUBDIR="${env.RUN_FROM_SUBDIR}"
      fi
+     for VAR in \${JOB_VARIABLES}; do
+       export ${VAR}
+     done
      sudo -H -u msk_jenkins cmake /scratch/source/\${SUBDIR} -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=${buildType} -DSUPPRESS_AUTO_DOC_BUILD=true \${CMAKE_EXTRA_ARGS}
       sudo -H -u msk_jenkins make ${env.MAKEOPTS}
     """
@@ -191,6 +194,9 @@ def doTest(String label, String buildType) {
     if [ -z "\${CTESTOPTS}" ]; then
       CTESTOPTS="${env.MAKEOPTS}"
     fi
+    for VAR in \${JOB_VARIABLES}  \${TEST_VARIABLES}; do
+       export ${VAR}
+    done
     sudo -H -u msk_jenkins ctest --no-compress-output \${CTESTOPTS} -T Test -V || true
     sudo -H -u msk_jenkins sed -i Testing/*/Test.xml -e 's_\\(^[[:space:]]*<Name>\\)\\(.*\\)\\(</Name>\\)\$_\\1${label}.${buildType}.\\2\\3_'
     sudo -H -u msk_jenkins cp -r /scratch/build-${JOB_NAME}/Testing "${WORKSPACE}"