1

I've written a number of unit tests for a Qt application using QTest which are packaged into a separate executable and can be run from a terminal. Both executables can be compiled and run fine from both my desktop and my Jenkins server.

However, when I try to run these unit tests via a job on Jenkins using SSH, I receive the following error:

qt.qpa.xcb: could not connect to display 
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vkkhrdisplay, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, xcb.

I assume that this is an issue with SSH not supporting graphical interfaces, but I would assume Qt must have a way of running unit tests over SSH for continuous integration? Or is this not possible? This uses version 6.2.2 of Qt.

Ozmydis
  • 53
  • 4

1 Answers1

0

Qt applications are graphical. When you are SSH-ing into the Jenkins server you shell on the server will not have a properly configured DISPLAY variable.

What does a DISPLAY variable do?

The default now is :0, which is short for connect to the server at IP address 127.0.0.1 using the first display (0).

The display server in your case is likely the system you are logged into at the time you SSH to the Jenkins server. So you will need to work out the IP address of your system. That is usually as easy as running who: risner pts/0 2022-09-05 06:50 (203.0.113.2)

Set your DISPLAY variable:

export DISPLAY=203.0.113.2:0 for zsh/bash/sh/ksh

setenv DISPLAY 203.0.113.2:0 for csh/tcsh

James Risner
  • 5,451
  • 11
  • 25
  • 47