JKI Blog

Fixed: LabVIEW user dialogs block Jenkins continuous integration build

Aug 26, 2021 8:40:37 PM Published by Jim Kring Leave a comment

Automating the build process of your LabVIEW application on a dedicated server as part of a "continuous integration" process for your project is extremely helpful to your team for many reasons. One popular tool for LabVIEW build automation is Jenkins.

One challenge in doing so (even if you follow all the best practices for using Jenkins with LabVIEW) is that LabVIEW and other application error dialogs (and other windows waiting for user input) can pop up during the process and block the build.

Jenkins Blocked by LabVIEW

When this happens, Jenkins shows a mysterious build timeout error in the build logs.

Examples of these types of dialog windows that will block a build are:

  • LabVIEW Activation Dialog showing that LabVIEW activation has expired or will expire soon
  • LabVIEW Automatic Recovery Error dialog stating that LabVIEW crashed the last time it was run and that there are auto-saved VIs that can be restored
  • Various Other Dialogs related to build errors, required logins, and more

Unfortunately, since Jenkins is running as a Windows service, you won't see these application windows (they are running in Windows Session 0 and not the user session), and so it can be terribly difficult to figure out and resolve the root problem.

Side Note: One possibility for seeing these application windows and dialogs of services is to use Interactive Services Detection.  However, this can be quite challenging to get working correctly.


However, there is hope...

Running Jenkins in the Current User Session

To work around this challenge, you can simply run Jenkins in the current user session (instead of as a Windows service).

To do this, create a batch file named start_jenkins_in_user_session.bat with the following contents:

set JENKINS_HOME="C:\Program Files (x86)\Jenkins"

jenkins.exe stop
java -jar jenkins.war --httpPort 8080


The, run the batch file by double-clicking it (or if you don't want to create a batch file, then you can run the commands from a cmd.exe command prompt).

These commands do the following (line-by-line):

  1. sets the JENKINS_HOME environment variable to the Jenkins installation directory, which can helpful for avoiding errors when Jenkins starts up.
  2. Sets the Jenkins installation folder as the current working directory.
  3. stops the Jenkins service (you can also do this from the services control panel, and you may wish to set it to start up manual startup instead of automatic startup)
  4. starts Jenkins in the current user session (the batch file's process), listening on port 8080 for web browser connections -- you can choose a different port number if you like

Success! Open Jenkins in your Browser

You can then open your web browser to http://localhost:8080 to start a new build or configure Jenkins.

Now, when your build is running LabVIEW, VIPM, and other apps with user interface windows will open in your current user session and you'll be able to interact with them and see why your build might be stuck waiting on user input.

Build a LabVIEW app

Bonus! Running Jenkins at Startup (in user session)

To make Jenkins run in a user session at startup (when the user logs in), you can create a batch file and put it in the startup folder of your user account.  We've also added a bonus feature of running the batch file's console window minimized to the taskbar.

C:\Users\{username}\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\start_jenkins_in_user_session.bat

@echo off

rem // Run self minimize (detects if not minimized and re-runs itself)
if not DEFINED IS_MINIMIZED set IS_MINIMIZED=1 && start "" /min "%~dpnx0" %* && exit

rem // Set JENKINS_HOME folder environment variable
set JENKINS_HOME="C:\Program Files (x86)\Jenkins"

rem // Set Jenkins installation folder as current working directory

rem // Stop jenkins service and ignore any errors
jenkins.exe stop > nul

rem // Starts jenkins at http://localhost:8080 (change to any port desired)
java -jar jenkins.war --httpPort 8080java -jar jenkins.war --httpPort 8080


That's all! Good luck and let us know if you need help with need help with LabVIEW (or LabVIEW training), have any suggestions, or if there's anything else you'd like to share with us. Until then, wishing you Happy Automated LabVIEW Application Building from all of us at JKI!

Tags: build, continuous integration, jenkins, LabVIEW tip, windows

Subscribe to Email Updates

Recent Posts

Posts by Topic

see all