Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-17127

Pass DISPLAY as environment variable to Maven builds

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Cannot Reproduce
    • Icon: Minor Minor
    • xvfb-plugin
    • None
    • Debian 6.0.3
      Jenkins 1.501
      Xvfb plugin 1.0.7

      For a freestyle project with an "Invoke top-level Maven targets" build step and the Xvfb plugin enabled, the display number is not passed in the DISPLAY environment variable, but as a property, instead:

      jenkins@ci4:~$ env|grep DISPLAY
      DISPLAY=:85
      jenkins@ci4:~$ ps -ef|grep firef
      jenkins  31202 22976  0 17:48 ?        00:00:00 /bin/sh /opt/maven3.0.4/bin/mvn -f pom.xml -Dtestsuite=Document -DDISPLAY=:7 clean install -B -Dwebdriver.firefox.bin=/opt/firefox-esr/firefox -Dtest=TestSuiteDocument -Djava.io.tmpdir=/home/jenkins/workspace/selenium-tests/tmp -Dmaven.repo.local=/home/jenkins/workspace/selenium-tests/.repository
      jenkins  31236 31202 19 17:48 ?        00:00:09 /opt/java/bin/java -Djava.io.tmpdir=/tmp/tmp_maven.31202.tmp -Xms512m -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=512m -classpath /opt/maven3.0.4/boot/plexus-classworlds-2.4.jar -Dclassworlds.conf=/opt/maven3.0.4/bin/m2.conf -Dmaven.home=/opt/maven3.0.4 org.codehaus.plexus.classworlds.launcher.Launcher -f pom.xml -Dtestsuite=Document -DDISPLAY=:7 clean install -B -Dwebdriver.firefox.bin=/opt/firefox-esr/firefox -Dtest=TestSuiteDocument -Djava.io.tmpdir=/home/jenkins/workspace/selenium-tests/tmp -Dmaven.repo.local=/home/jenkins/workspace/selenium-tests/.repository
      jenkins  31375 31323 40 17:49 ?        00:00:16 /opt/firefox-esr/firefox -foreground
      jenkins  31416 27994  0 17:49 pts/0    00:00:00 grep firef
      jenkins@ci4:~$ sed -e 's/.*DISPLAY=//' /proc/31375/environ
      :85...
      

      Outside of the build, the DISPLAY variable is set to :85, Jenkins passes -DDISPLAY=:7 to Maven, but the firefox process still has DISPLAY=:85 in its environment.

      If we convert our build step to "Execute shell", everything works as expected but then we have to "hard-code" the Maven version instead of choosing one from the Maven installations that we configured globally.

      Would it be hard to change the behaviour so that the DISPLAY environment variable gets set instead, or in addition to the Java property?

            zregvart zregvart
            ustuehler Uwe Stuehler
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: