Prerequisites
- A running Jenkins instance (local or remote).
- The NodeJS Plugin installed in your Jenkins environment.
- A Git repository containing your Bruno collections and a
Jenkinsfile.
Automate API Testing with Jenkins
Step 1: Organize Your Bruno Collections
Ensure your Bruno collections and environment files are properly organized within your Git repository. A typical structure looks like this:Step 2: Configure Node.js in Jenkins
Before running Bruno CLI, you need to ensure Jenkins can access a Node.js runtime environment.-
Install the NodeJS Plugin:
- Navigate to
Manage Jenkins>Plugins. - Select the
Available pluginstab, search for “NodeJS”, and install it.
- Navigate to
-
Configure a Node.js Installation:
- Go to
Manage Jenkins>Tools(underSystem Configuration). - Scroll down to the
NodeJS installationssection. - Click
Add NodeJS. - Provide a descriptive Name (e.g.,
Node.js 18). This exact name will be used in your Jenkinsfile. - Check
Install automaticallyand select your desiredNode.js version(e.g.,NodeJS 18.20.8). - Crucially, ensure the checkbox “Provide Node & npm folder to PATH” is checked. This ensures
nodeandnpmcommands are available to your pipeline. - Click
Save.
- Go to
Step 3: Create Your Jenkinsfile
Create a file namedJenkinsfile in the root of your Git repository. This file defines the steps of your CI pipeline.
Step 4: Configure Jenkins Pipeline Job
-
Create a New Jenkins Job:
- From the Jenkins Dashboard, click New Item.
- Enter an Item name (e.g., bruno-api-tests-pipeline).
- Select Pipeline as the item type and click OK.
-
Configure Job Details:
- In the job configuration page, navigate to the Pipeline section.
- Set Definition to Pipeline script from SCM and Choose your SCM (e.g., Git).
- Enter your Repository URL (e.g.,
https://github.com/your-org/your-repo.git). - Specify any Credentials if your repository is private.
- Set Branches to build to */main (or the branch containing your Jenkinsfile).
- Ensure Script Path is Jenkinsfile (this is the default).
- Click Save to finalize your job configuration.
Step 5: Run and Monitor Your Pipeline
-
Trigger a Build:
- From your Jenkins pipeline job page, click Build Now (in the left-hand menu) to manually start the pipeline.
-
Monitor Progress:
- Observe the Build History section to see the status of your builds (green checkmark for success, red cross mark for failure).
- Click on a specific build number, then select Console Output to view real-time logs and detailed execution steps.
-
View Test Results:
- Once a build that generated results.html completes, navigate to that specific build’s page.
- Look for the Artifacts section (usually on the left sidebar or at the top of the build summary).
- Click on
results.htmlto download the report, then open it in your web browser for detailed test outcomes.