Wednesday, October 18, 2017

Configure Jenkins and Xvfb plugin on Ubuntu

Introduction

Some build workflows in Jenkins require the display. If you run the build of Java application in console following exception might happen.
Exception in thread "main" java.lang.InternalError: Can't connect to X11 window server using '' as the value of the DISPLAY variable.
I found a solution how to fix it using  Xvfb.

Installation of Xvfb

1. To install Xvfb run following command in terminal.
sudo apt-get update
sudo apt-get install xvfb

Installation of Xvfb Plugin

1. I have an assumption that Jenkins is installed and running on Ubuntu 16.04. Please follow installation instructions to install Jenkins in case you do not have running Jenkins. 
2. Install Xvfb plugin. Please follow instructions for plugins installation.


Configuration of Xvfb Plugin

If plugin configured incorrectly you might have the following exception:
ERROR: No Xvfb installations defined, please define one in the configuration. Once defined you’ll need to choose one under Advanced options for Xvfb plugin job settings and save job configuration.
To fix it:
1. Navigate to  Manage Jenkins → Global Tool Configuration → Xvfb installation
2. Set Name: Xvfb
3. Set Directory in which to find Xvfb executable: /usr/bin


Xvfb installation

Troubleshooting

1. In case you still have the issue, try to play with the configuration of 'Start Xvfb before the build, and shut it down after.' step. E.g.

'Start Xvfb before the build, and shut it down after' step

Tuesday, October 17, 2017

Recursively copy files of a specific folder into a single flat folder on Windows

Recursively copy files of a specific folder into a single flat folder on Windows

Use following script, with appropriate folders.

@echo off
for /r "{full path to source dir}" %%a in (*) do copy "%%a" "{full path to flatten dir}"

Thursday, October 5, 2017

VirtualBox: Accessing shared folder from Ubuntu guest

Preconditions

  • VirtualBox is installed.
  • Ubuntu 16.04 is running in VirtualBox.

Instruction

1. Create shared folder. Click settings → Shared Folders → Click 'Add a new shared folder' button.

Shared folders

2. Specify name and path to the folder you want to make shared.

Add shared folder

3. In VirtualBox click 'Devices' → Insert Guest Additions CD image → Run with sudo permissions VBoxLinuxAdditions.run program from mounted disk.

VBoxLinuxAdditions.run

4. Make folder

sudo mkdir /home/{user_name}/shared-folder 

5. Mount the folder with the command:

sudo mount -t vboxsf {folder_name_from_step_2} /home/{user_name}/shared-folder

6. Done.