Jenkins IntegrationJenkins Configuration to Execute the Scripts in Virtual Machines

Jenkins Configuration to Execute the Scripts in Virtual Machines

Configure Jenkins to execute algoQA-generated scripts across virtual machines using distributed builds, node configuration, and parameterized jobs.

Installing Jenkins

To download and install Jenkins, click here.

Prerequisites

After installing Jenkins, ensure you have the following plugins installed:

  • Parameterized Trigger plugin - Install this plugin to enable parameterized builds. This plugin allows you to trigger new builds upon completion of existing builds.

  • Copy To Slave plugin or Copy Data to Workspace plugin - Install this plugin for efficient data transfer between master/controller and slave nodes in your Jenkins environment.

  • Node and Label parameter plugin - Install this plugin to use node and label parameters in your build configurations.

  • Git plugin - Install this Git plugin to integrate Git repositories with Jenkins for source code management.

    You can install these plugins from the Jenkins dashboard by navigating to Manage Jenkins > Manage Plugins > the Available tab. For more details, refer to the article on installing a plugin. Ensure that these plugins are installed and configured according to your project requirements.

  • Hardware requirements:

    System AreaRequirements
    Minimum RAM8 GB
    Core CPU2
    Minimum storage30 GB
  • Software Requirements:

    System AreaRequirements
    JavaStable versions 8 and 11
    MavenLatest version
    JenkinsLatest version
  • Click here to configure the compatible versions of Java and Maven.

Working with a Project

Creating a New Folder for a Project

Perform the following:

Navigate to the Dashboard and select 'New View'.

From the Jenkins Dashboard, select New View to create a new view for your project.

Jenkins side menu with New Item, People and Manage Jenkins links, New View highlighted

In the View Name textbox, enter your project name.

For example, TheAlgoQA. Make sure to provide the folder name without any spaces. You can also rename the folder by clicking the Rename icon in the left pane.

Jenkins view name field with Build Pipeline View, List View and My View options

Choose either 'List View' or 'My View' based on your requirement to view the corresponding page.

Click OK to create a new folder.

Creating a New Job within the TheAlgoQA Project Folder

Perform the following to create a new job named "DownloadAlgoQAJob" within the "TheAlgoQA" project folder in Jenkins. This job helps you to download scripts from a Git repository and distribute them to machines for execution. In this case, machine refers to the virtual machine where you execute your scripts.

In the Dashboard, select the ProjectName (TheAlgoQA) in the breadcrumbs.

In the left pane, click 'New Item' or the associated icon.

Jenkins side menu with New Item, People and Manage Jenkins links, New View highlighted
Jenkins left pane with New Item option highlighted

Enter an item name screen appears.

In this screen, enter the project name (DownloadAlgoQAJob) into the Enter an item name textbox.

Jenkins New Item page with item name field and Freestyle project option highlighted

Choose the 'Freestyle project' option and then select OK to view the next screen.

Jenkins General tab with Source Code Management None or Git options and Build Triggers checkboxes

In the Source Code Management section, select the Git option to enter Git repository details.

In the following screen, enter the Repository URL, select none, enter the branch specifier, and click Save.

Jenkins Source Code Management panel with Git selected and Please enter Git repository error message

Configure Build Steps: Select the Build tab or navigate to the Build section to view the Build screen.

In this screen, enter the project name to build and the node details, as shown. In Jenkins, when configuring the DistributeAlgoQA project and providing the required node details, you are setting up the process for distributing scripts to a machine. This allows you to specify how the scripts must be distributed and executed on different nodes or machines within the Jenkins environment.

Jenkins Build Triggers section showing project name error and All Nodes for Label Factory fields

Configuring the nodes: This process allows you to specify where the distributed scripts must be executed within the Jenkins environment.

Perform the following:

  1. In the Dashboard screen, select Manage Jenkins in the left pane.
  2. Select Manage Nodes and Clouds in the System Configuration section.
    Jenkins System Configuration screen with Manage Nodes and Clouds option highlighted
  3. Select New Node from the left pane.
  4. In the New Node screen, enter the node name, select the Permanent Agent option to connect permanently to the Controller/Master, and click OK.
    New Node screen with Node name field, Permanent Agent and Copy Existing Node options
  5. In the Node Details screen, enter the details as shown in the screenshot. Note that while entering the number of executors, it is recommended to ensure that the number of executors in Jenkins does not exceed the number of virtual CPUs available. Click Save.
    Jenkins node configuration page for VM1 with executors, remote root directory and Labels fields

To log in to the virtual machine (VM) using Remote Desktop Protocol (RDP) and connect it to Jenkins, perform the following:

  1. Use commands to initiate an RDP connection to the VM. For example: On Windows, you can use mstsc command with appropriate parameters to connect to the VM. On Linux, you can use xfreerdp or rdesktop commands.

  2. Establish the connection:

    Once the RDP connection is established, execute scripts on the VM to interact with Jenkins. Make sure to install a Jenkins CLI tool on the VM to interact with Jenkins remotely. This tool allows you to trigger builds, query job statuses, and perform other Jenkins-related tasks.

    Note: The steps outlined above for logging in to the virtual machine (VM) and connecting it to Jenkins may vary depending on the specific environment and configurations.

Adding a build step

Repeat the steps described in creating a project folder and creating a new job until step 4, and then enter the following details of the required test scripts.

Jenkins job General tab showing FeatureList, Featurename string parameters and Node label default value

To execute commands using a Linux machine, perform the following:

  1. After creating a job, navigate to the Build section under the General tab.
  2. Select the Add build step dropdown to select the Execute Shell option.
    Jenkins Add build step dropdown with Execute shell option highlighted among build step choices
  3. Run the following Maven command to execute scripts: mvn test. Make sure you set the path similar to the following example: cd /home/centos/Jenkins/workspace/DistributeAlgoQA/AlgoQA
    Jenkins Execute shell build step showing mvn and mono command script
  4. Save the configurations. The projects created will be displayed.
    Jenkins dashboard listing AlgoQAJob, DistributeAlgoQA and DownloadAlgoQAJob projects

Executing the scripts: Perform the following:

  1. Navigate to the AlgoQA job created earlier.
  2. Select the Build with Parameters option in the left pane.
  3. Enter the test case tags into the FeatureList text box, Feature name, and Node details.
    Jenkins Build with Parameters page showing FeatureList, Featurename and Node fields
  4. Click Build.
  5. Click the link corresponding to the latest build in the Build History section.
  6. Click the Console Output link on the left pane to view the output for the commands you entered. The console output indicates that Jenkins is successfully executing the commands.