• Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • xvfb-plugin
    • None
    • Docker container with ubuntu 14.04
      apt-get install -y xvfb xfonts-100dpi xfonts-75dpi xfonts-cyrillic xorg dbus-x11
      apt-get install -y freerdp-x11

      My Jenkinsfile use Xvfb:

      ...
              parallel(
                  intTests: {
                      sh "mvn -B install -P intTests"
                  }, funcTests: {
                      wrap([$class: 'Xvfb']) {
                          sh "mvn -B install -PfuncTests"
                      }
                  }, failFast: false
              )
      ...
      

      In test I try to run xfreerdp:

      xf_pre_connect: failed to open display: :0
      Please check that the $DISPLAY environment variable is properly set.
      freerdp_pre_connect failed
      

      If I manually export DISPLAY variable all work perfect.
      May be there is a way to configure Xvfb in Jenkinsfile?

          [JENKINS-36355] Xvfb does not export DISPLAY variable

          zregvart added a comment -

          Yurie, thanks for reporting the issue. Can you run sh "env" in your wrap block? The DISPLAY environment variable should be set there. Also can you provide the versions of the Xvfb plugin, Jekins and console log of your pipeline job?

          zregvart added a comment - Yurie, thanks for reporting the issue. Can you run sh "env" in your wrap block? The DISPLAY environment variable should be set there. Also can you provide the versions of the Xvfb plugin, Jekins and console log of your pipeline job?

          Yuriy Burtsev added a comment -

          You are right DISPLAY=:0 variable is present in env:

          [Pipeline] wrap
          Xvfb starting$ docker exec 98986538cd21937d631f1e122608275a939f6dba9c7c057b580067d02297620d env _JENKINS_XVFB_COOKIE=3dd4a4d5-eb45-44df-b3d5-7949a87e653c Xvfb :0 -screen 0 1024x768x24 -fbdir /home/jenkins/jenkins-node-1.651.3/xvfb-10-4491495452708784588.fbdir
          + env
          JENKINS_HOME=/var/lib/jenkins
          LANGUAGE=ru_RU:ru
          HOSTNAME=98986538cd21
          HUDSON_URL=***
          HOME=/home/jenkins
          BUILD_URL=***
          JENKINS_SERVER_COOKIE=durable-51fd50bf64125932b5aed0f5bbfa2581
          MAVEN_HOME=/usr/share/maven
          NODE_NAME=oraci1
          EXECUTOR_NUMBER=1
          TERM=xterm
          BUILD_DISPLAY_NAME=#10
          HUDSON_HOME=/var/lib/jenkins
          PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
          BUILD_ID=10
          BUILD_TAG=***
          DISPLAY=:0
          JENKINS_URL=***
          LANG=ru_RU.UTF-8
          JOB_URL=***
          BUILD_NUMBER=10
          HUDSON_SERVER_COOKIE=cf7cadd9158162e5
          CLASSPATH=
          JOB_NAME=***
          JAVA_HOME=/usr/lib/jvm/java-8-oracle
          LC_ALL=ru_RU.UTF-8
          PWD=/home/jenkins/jenkins-node-1.651.3/workspace/***/test-xvfb
          [Pipeline] sh
          [test-xvfb] Running shell script
          + xfreerdp -a 32 -g 1024x768 -k ru-ru -p *** -u ***--app --plugin rail --data calc.exe -- 10.196.2.98
          loading plugin rail
          xf_pre_connect: failed to open display: :0
          Please check that the $DISPLAY environment variable is properly set.
          freerdp_pre_connect failed
          [Pipeline] }
          Xvfb stopping
          [Pipeline] // wrap
          [Pipeline] }
          $ docker stop 98986538cd21937d631f1e122608275a939f6dba9c7c057b580067d02297620d
          $ docker rm -f 98986538cd21937d631f1e122608275a939f6dba9c7c057b580067d02297620d
          

          Version Xvfb plugin 1.1.3
          Version Jenkins 1.651.3
          But if I run docker container manually add DISPLAY variable run Xvfb with command:

          Xvfb :0 -screen 0 1024x768x24 -fbdir /tmp
          

          all work perfect.

          Yuriy Burtsev added a comment - You are right DISPLAY=:0 variable is present in env: [Pipeline] wrap Xvfb starting$ docker exec 98986538cd21937d631f1e122608275a939f6dba9c7c057b580067d02297620d env _JENKINS_XVFB_COOKIE=3dd4a4d5-eb45-44df-b3d5-7949a87e653c Xvfb :0 -screen 0 1024x768x24 -fbdir /home/jenkins/jenkins-node-1.651.3/xvfb-10-4491495452708784588.fbdir + env JENKINS_HOME=/ var /lib/jenkins LANGUAGE=ru_RU:ru HOSTNAME=98986538cd21 HUDSON_URL=*** HOME=/home/jenkins BUILD_URL=*** JENKINS_SERVER_COOKIE=durable-51fd50bf64125932b5aed0f5bbfa2581 MAVEN_HOME=/usr/share/maven NODE_NAME=oraci1 EXECUTOR_NUMBER=1 TERM=xterm BUILD_DISPLAY_NAME=#10 HUDSON_HOME=/ var /lib/jenkins PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin BUILD_ID=10 BUILD_TAG=*** DISPLAY=:0 JENKINS_URL=*** LANG=ru_RU.UTF-8 JOB_URL=*** BUILD_NUMBER=10 HUDSON_SERVER_COOKIE=cf7cadd9158162e5 CLASSPATH= JOB_NAME=*** JAVA_HOME=/usr/lib/jvm/java-8-oracle LC_ALL=ru_RU.UTF-8 PWD=/home/jenkins/jenkins-node-1.651.3/workspace /***/ test-xvfb [Pipeline] sh [test-xvfb] Running shell script + xfreerdp -a 32 -g 1024x768 -k ru-ru -p *** -u ***--app --plugin rail --data calc.exe -- 10.196.2.98 loading plugin rail xf_pre_connect: failed to open display: :0 Please check that the $DISPLAY environment variable is properly set. freerdp_pre_connect failed [Pipeline] } Xvfb stopping [Pipeline] // wrap [Pipeline] } $ docker stop 98986538cd21937d631f1e122608275a939f6dba9c7c057b580067d02297620d $ docker rm -f 98986538cd21937d631f1e122608275a939f6dba9c7c057b580067d02297620d Version Xvfb plugin 1.1.3 Version Jenkins 1.651.3 But if I run docker container manually add DISPLAY variable run Xvfb with command: Xvfb :0 -screen 0 1024x768x24 -fbdir /tmp all work perfect.

          Yuriy Burtsev added a comment - - edited
                  withEnv(['DISPLAY=:0']) {
                      sh '/usr/bin/Xvfb :0 -screen 0 1024x768x24 -fbdir /tmp &'
                      sh 'xfreerdp -a 24 -g 1024x768 -k ru-ru -p *** -u ***--app --plugin rail --data "calc.exe" -- 10.196.2.98'
                  }
          

          work for me.

          Yuriy Burtsev added a comment - - edited withEnv([ 'DISPLAY=:0' ]) { sh '/usr/bin/Xvfb :0 -screen 0 1024x768x24 -fbdir /tmp &' sh 'xfreerdp -a 24 -g 1024x768 -k ru-ru -p *** -u ***--app --plugin rail --data "calc.exe" -- 10.196.2.98' } work for me.

          Yuriy Burtsev added a comment -

          If need more details I try to help.

          Yuriy Burtsev added a comment - If need more details I try to help.

          zregvart added a comment -

          I believe I've tracked down the cause of the problem, in fact it was two issues that were causing this behavior: race condition between the test if Xvfb was running when started by docker exec and use of frame buffer directory for Xvfb that was not mounted as a volume in the started docker container. Now the timeout value defaults to 1 second, that should be enough to alleviate the race condition and frame buffer directory is created within the workspace of the build that should be present in the docker container.

          I've released a beta version of the Xvfb plugin to the experimental update center could you install the version 1.1.4-beta1 from there and test if this fixed your problem?

          zregvart added a comment - I believe I've tracked down the cause of the problem, in fact it was two issues that were causing this behavior: race condition between the test if Xvfb was running when started by docker exec and use of frame buffer directory for Xvfb that was not mounted as a volume in the started docker container. Now the timeout value defaults to 1 second, that should be enough to alleviate the race condition and frame buffer directory is created within the workspace of the build that should be present in the docker container. I've released a beta version of the Xvfb plugin to the experimental update center could you install the version 1.1.4-beta1 from there and test if this fixed your problem?

            zregvart zregvart
            burtsevyg Yuriy Burtsev
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: