How to Run GenRocket Scenarios via Jenkins

This article will lead you through integrating GenRocket Scenarios into your Jenkins Continuous Integration (CI) pipeline. This article assumes you already have your Jenkins Server setup. 

Note: To learn how to run GenRocket Scenarios via Jenkins for the Mac OS or Linux operating systems, please see Mac OS/Linux: How do I run GenRocket Scenarios via Jenkins?

In This Article

Step 1 - Download and Install the GenRocket Runtime on Jenkins Server

The GenRocket Runtime consists of a set of Jars that can be loaded and executed by a Java Virtual Machine (JVM) to load and run GenRocket Scenarios on your Jenkins Server. 

This step is identical to downloading and installing the GenRocket Runtime onto your local computer. If you have not already performed this step, please refer to the page below: 

Step 2 - Set the GenRocket Environment Variables in Jenkins 

You must set the Environment Variable GEN_ROCKET_HOME to the path where you downloaded the GenRocket Runtime on your Jenkins Server and then update the PATH variable. 

Step 2a - Access the Configure System Form in Jenkins

  • Click on Manage Jenkins in the left sidebar.

  • Next, click on Configure System underneath Manage Jenkins.

Step 2b - Update Environment Variables in Jenkins

  • On the Configure System Form, scroll down to the Environment Variables section to add and update your environment variables.

  • Set the value of the GEN_ROCKET_HOME variable value to your local system path. 

  • Next, set or update the environment variable PATH value to $GEN_ROCKET_HOME/bin directory. 

  • This value is necessary for Jenkins batch to recognize the genrocket command as a GenRocket Runtime command.

Step 3 - Add the Jenkins Server to the GenRocket Web Platform 

If you have not already done so, log into the GenRocket Web Platform and add the Jenkins Server to GenRocket from the My Organization page. To see step-by-step instructions, click here.

Once added, an Org Admin can download the Server Profile so that the Server may be used to execute GenRocket Scenarios. 

  • Select the Servers tab and then click New Server
  • Add a unique Name, Description (optional), and Email ID (Optional).

Step 4 - Update Resource Variables with the Appropriate Values

Next, you will need to update resource variables in the GenRocket Web Platform with the appropriate values with respect to Jenkins Server. These steps will need to be followed for each resource that is needed for the Jenkins Server.

  • Select the Jenkins Server within the Select Server drop-down menu.

  • Click the Pencil in the Resources pane and enter the output directory path for the Jenkins Server.
  • Click Save once finished.

Step 5 - Download your ServerProfile.grp File

  • Expand the Download drop-down menu in the Resources Pane.

  • Select Download ServerProfile.grp to download your server profile.

  • Place the ServerProfile.grp file in the .genrocket folder of your Jenkins server.

Step 6 - Run the genrocket -a command to Update Generator and Receiver Jars

  • Open your terminal or command line application on the Jenkins Server.
  • Run the genrocket -a command to update Generator and Receiver Jars.

Step 7 - Create a Jenkins Job to Run GenRocket Scenarios 

  • Open Jenkins and create a new job by clicking on New Item in the left sidebar.

  • Add an item name for the new job.

  • Select Freestyle project.

  • Click OK at the bottom of the form.

Step 8 - Navigate to the Build Tab for the Jenkins Job

  • You will now be on the Configuration page for the new job after creating it.

  • Click on the Build Tab to select it and make configuration changes.

Step 9 - Select Execute Windows Batch Command

If you are currently not viewing the configuration for the Jenkins Job, then navigate to Jenkins Job > Configure > Build. Otherwise, continue with the steps below:

  • Scroll down to the Build section of the Build Tab for the Jenkins Job. 

  • Select Execute Windows Batch Command from the Add Build Step drop-down menu.

Step 10 - Update the Execute Windows Batch Command

The purpose of this step is to verify if the genrocket command is now getting verified as an internal or external command.

  • Update the command within the Execute Windows Batch command box to: genrocket.

  • Then, run the genrocket command to verify that the command is getting executed.

Step 11 - Run your Jenkins Job and Check Console Output for Errors

  • Run the build for the job and then view your Console Output.

  • If the build gets executed successfully, then you can skip to Step 13.

  • Otherwise, if the JAVA_HOME is not set and no 'java' command could be found in your PATH error appears in your console output, then please continue with Step 12.

Step 12 - Configure JAVA_HOME and PATH Values

  • As before, navigate to Manage Jenkins > Configure.

  • Set the environment variable for JAVA_HOME to reflect your System Path.

  • Then, update the PATH value to include $JAVA_HOME\bin.

    Note: The PATH value should appear like this once finished: $GEN_ROCKET_HOME\bin;$JAVA_HOME\bin.

Step 13 - Update the Execute Windows Batch Command to Run the Scenario

  • Navigate to Jenkins Job > Configure > Build.

  • Update the command in the Execute Windows Batch command box to: genrocket -d -r SCENARIO_NAME.grs.

  • Run the Scenario using the genrocket command.

  • If the Scenario runs successfully with a SUCCESS message on the console output window, then everything has been set up correctly at this point, and you can check the generated files in your given output directory path.

    Note: If a Could not find a profile.grp error appears in your output, complete Step 14.

Step 14 - Could Not File profile.grp Error Message

If you encounter a Could not find a profile.grp error message, then please complete the steps shown below: 

  • Note or copy the path where Jenkins is looking for the profile.grp file.

  • Navigate to the same path where Jenkins is currently looking for a profile.grp file and paste the downloaded server profile.grp file into this location.

  • Run the build again for the Jenkins Job after these steps have been completed and check the Console Output for a SUCCESS message.

    Note: After following the above steps, you will be able to move forward with a SUCCESS message on the console output window.