Jenkins IntegrationExecuting Scripts Using Jenkins Freestyle Project

Executing Scripts Using Jenkins Freestyle Project

This article provides detailed instructions for setting up Jenkins, configuring Java and Maven, creating and running a Jenkins job, and managing projects for executing Selenium scripts. It covers all necessary steps to automate builds and test executions in Jenkins using a Freestyle project.

Prerequisites

  • Install Jenkins by following the steps described in Jenkins Installation
  • Configure Java and Maven by following the steps described in Configure Java and Maven
  • Navigate to the algoQA-generated script folder and open Command Prompt by typing cmd in the folder address bar. Run the 'mvn test' command to execute the scripts, then wait until the 'Build Success' message appears. This indicates that your scripts have been executed successfully.

Delete an Existing Project

In the Dashboard, to delete the existing script, select the scripts generated checkbox.

Jenkins Dashboard with Script-Execution job row and Success status icon highlighted

Select the Script Execution dropdown list to delete the project if there are any projects.

Jenkins project dropdown menu with Delete Project option highlighted

Click Yes to delete the project.

Creating a Job and Running a Build Using a Freestyle Project

Perform the following:

In the Dashboard screen, click Create a Job Plus icon and enter an item name.

Welcome to Jenkins page with Create a Job option highlighted
Jenkins new item name field with Freestyle project and Maven project options listed

Select the Freestyle project option and click OK.

New Item type list with Freestyle project option circled and OK button highlighted

In the Configure tab, select the Advanced Settings dropdown list.

Jenkins Configure page, General tab, with Advanced dropdown highlighted above Source Code Management

Select Use custom workspace option.

Jenkins Advanced build settings with Use custom workspace checkbox highlighted

Enter the Directory path.

Jenkins Use custom workspace checkbox checked with empty Directory field and error highlighted

Click Apply.

Jenkins job configuration page with Build Steps, Post-build Actions and Apply button highlighted

Click Save.

Build configuration page with Save button highlighted and green Saved confirmation banner

Click Configure.

Jenkins project page with Configure option highlighted in the left sidebar menu

Click the Add build step dropdown list.

Jenkins Build Environment tab with Add build step dropdown circled, and Save, Apply buttons

Click the Invoke Top-level Maven Targets option.

Jenkins Add build step dropdown with Invoke top-level Maven targets option highlighted

Select the Maven Version dropdown list.

Jenkins Invoke top-level Maven targets build step with Maven Version dropdown highlighted

Enter the goals and click Apply.

Jenkins Post-build Actions section with Save button and Apply button highlighted

Click Save.

Build configuration page with Save button highlighted and green Saved confirmation banner
Jenkins build configuration saved confirmation view

Click Build Now.

Jenkins project page with Build Now option highlighted in left sidebar menu

Select the Project from the Build History.

Jenkins project menu with Build Now, Configure options and Build History list showing highlighted build entry

Click Console Output.

Jenkins build page with Console Output menu item highlighted

The Console Output contains:

  • Build Information: Details about the build number, job name, and build status. For example, success, failure test results.
  • Log Messages: Output from build steps, including commands executed, and any log messages from scripts or applications.
  • Error Messages: Warnings and error messages if something went wrong during the build or testing process.
  • Environment Variables: Information about the environment in which the build is running, such as variable values.
  • Plugin Outputs: Messages from any installed plugins that are executing during the build process.