Hypertest Docs
HyperTestKnowledge Base
  • Quick Set-up
    • Install HyperTest
    • Deploy your application
    • Mirror Traffic
      • Using Kubernetes
      • Using Amazon ECS
      • Using Docker
      • Using Nginx
      • Using Goreplay
        • ElasticBeanStalk Script for Goreplay
      • Using Apache
      • Using IIS
      • Using Istio
      • Using Kong
      • Using HAProxy
      • Others
  • HyperTest Overview
    • Introduction
    • Architecture
  • Detailed Setup Guide
    • Detailed Setup Guide
      • Installation
        • Linux VM
        • Kubernetes Cluster
          • Hardware Requirements
          • Cluster Setup
            • EKS
              • Existing Application Load Balancer
              • Calculate Setup Cost for EKS Cluster
            • GCP
            • AKS
            • Self Managed
              • Microk8s with EKS-D
          • HyperTest Installation
      • Mirror Traffic
      • Configure HyperTest
      • Automate Starting a Test
        • CI Integration
          • GitHub Checks Integration
            • Mandatory checks
          • Gitlab Integration
          • Bitbucket Integration
          • Jenkins Pipeline
            • Jenkins Plugins for PR events
  • Upgrade HyperTest
    • Upgrade HyperTest
      • Linux VM
      • Kubernetes Cluster
  • User Guides
    • Usage Guide
      • Install and Configure HyperTest
        • Install HyperTest
        • Configure Base DNS
        • Add New Service
      • Tests Runs and Analysis
        • View Test Cases
        • Start New Test Run
        • Understand Your Test Run Analysis
        • Prioritize Your Error Types
        • Track Bugs
        • Ignore Errors/Desired Changes
        • View/Download Report
        • View Consolidated Dashboard Reports
        • Sign-off Reports
        • Reduce Execution Time
        • Deduplication Rules
      • Troubleshooting and FAQs
    • Best Practices Guide
      • Cost Optimization
    • Dashboard Tour
      • Dashboard
      • All Sessions
      • Regression Report
      • Notifications
      • First Test Run
      • Interactions
      • Custom Analysis
      • Configuration
    • User Management
      • Create Admin User
      • Roles, Groups & Users
      • Enabling User Signup
    • Other Guides
      • Basic Nginx Auth for Linux HT
  • Middleware
  • Advanced Features
    • Import test cases from Postman
  • Change Log
  • Troubleshooting
  • FAQs
    • Setup
    • General
    • Regression Report
  • Glossary
    • Session
Powered by GitBook
On this page
  • Steps:
  • Sample files for CI/CD with Generic Trigger
  • Jenkins Plugins for PR events
  • Sample files for CI/CD with Generic Trigger
  1. Detailed Setup Guide
  2. Detailed Setup Guide
  3. Automate Starting a Test
  4. CI Integration
  5. Jenkins Pipeline

Jenkins Plugins for PR events

PreviousJenkins PipelineNextUpgrade HyperTest

Last updated 1 year ago

You can use Generic Webhook Trigger plugin for triggering Jenkins builds on PR events and get the pr number from the payload it sends to trigger test runs from HyperTest CLI.

To achieve it, you will have to do the following

  1. Send webooks to Jenkins webhooks trigger on pull request events from your codebase

  2. Install Generic Webhook Plugin in Jenkins

  3. Configure Plugin in your pipeline

Steps:

1. Send Webhooks to Jenkins

  1. Go to Webhooks

  2. Add a new Webhook

  3. Payload Url: Wehook trigger listens on /generic-webhook-trigger/invoke.

If you have any authentication on jenkins, pass it in webhook url like below http://<username>:<password>:@<jenkins_ip>:<jenkins_port>/generic-webhook-trigger/invoke

  1. Content type: application/json

  2. Add any secret if required

  3. To trigger the webhooks on pull request events only, select let me select individual events and check pull requests

  4. Save and add Webhook

​

2. Install Plugin in Jenkins

Install Generic Webhook Plugin from Jenkins plugins page and restart Jenkins after the plugin is installed

3. Configure Plugin in pipeline to pick PR number

  1. Go to configure tab in your pipeline

  2. Check the Generic Webhook plugin option under Build triggers

  1. To fetch the pull request id, add the parameter in post content parameter Variable Name: pull_request_number Expression: $.pull_request.number

  2. Add other envs/token or other settings if required and save

  3. Now you access the parameter by $pull_request_number

  4. Export HT_PR parameter inside your Jenkinsfile export HT_PR=$pull_request_number

Sample files for CI/CD with Generic Trigger

Alternatively you can also control environment variables of Generic Webhook plugin from your Jenkinsfile like below, and add it in HT_PR in environment section

Jenkins Plugins for PR events

2. Install Plugin in Jenkins

Install Generic Webhook Plugin from Jenkins plugins page and restart jenkins after the plugin is installed

3. Configure Plugin in pipeline to pick PR number

  1. 1.Go to configure tab in your pipeline

  2. 2.Check the generic webhook plugin option under Build triggers

  1. 3.To fetch the pull request id, add the parameter in post content parameter Variable Name: pull_request_number Expression: $.pull_request.number

  2. 4.Add other envs/token or other settings if required and save

  3. 5.Now you access the parameter by $pull_request_number

  4. 6.Export HT_PR parameter inside your Jenkinsfile export HT_PR=$pull_request_number

Sample files for CI/CD with Generic Trigger

Alternatively you can also control environment variables of Generic Webhook plugin from your Jenkinsfile like below, and add it in HT_PR in environment section

Jenkinsfile
#!/usr/bin/env groovy

// This is a basic workflow to help you get started with Jenkins Pipeline

// This pipeline should ony be triggered when you raise a PR/make changes to it

pipeline {
    agent any
    
    triggers {
      GenericTrigger(
        genericVariables: [
          [key: 'pull_request_number', value: '$.pull_request.number'],
        ],
        causeString: 'Triggered on $action in $pull_request_number',
        regexpFilterExpression: '',
        regexpFilterText: '',
        printContributedVariables: false,
        printPostContent: false
      )
    }
    
    // Setting a few env for HyperTest Cli
    environment {
       HT_BASE_URL='http://<hypertest-vm-ip>:<dashboard-port>'
       HT_COMMIT_HASH="${sh (returnStdout: true, script: 'echo ${GIT_COMMIT}').trim()}"
       HT_BRANCH="${sh (returnStdout: true, script: 'echo ${GIT_BRANCH}').trim()}"
       HT_PR="${sh (returnStdout: true, script: 'echo ${pull_request_number}').trim()}"
       HT_API_TOKEN='<ht-api-token>'
    }

    stages {
    
        // Steps to build your application
        stage('Build') { 
            steps {
                sh 'echo "steps to build"'
            }
        }
      
        // Steps to deploy your application
        stage('Deploy') {
            steps {
                sh 'echo "steps to deploy"'
            }
        }
        
          // Steps to test your application
        stage('Test') {
            steps {
                sh 'echo "steps to test"'
            }
        }
        
        // Steps to start a new test run
        stage('Start new test run') {
        
            steps { 
                sh 'echo "This job downloads HyperTest Cli and start a new test"'               
                sh 'printenv|sort'
                sh 'wget -O ht-cli.tar.xz https://hypertest-binaries-1.s3.ap-south-1.amazonaws.com/ht-cli/ht-cli-latest.tar.xz'
                sh 'tar xvf ht-cli.tar.xz'
                sh './hypertest can-run-test'
                sh './hypertest start-new-test'
            }
        }
    }

You can use Generic Webhook Trigger plugin for triggering Jenkins builds on PR events and get the pr number from the payload it sends to trigger test runs from HyperTest CLI.To achieve it, you will have to do the followingSend webooks to Jenkins webhooks trigger on pull request events from your codebaseInstall Generic Webhook Plugin in JenkinsConfigure Plugin in your pipelineSteps:1. Send Webhooks to JenkinsGo to WebhooksAdd a new WebhookPayload Url: Wehook trigger listens on /generic-webhook-trigger/invoke. If you have any authentication on jenkins, pass it in webhook url like below http://<username>:<password>:@<jenkins_ip>:<jenkins_port>/generic-webhook-trigger/invokeContent type: application/jsonAdd any secret if requiredTo trigger the webhooks on pull request events only, select let me select individual events and check pull requestsSave and add Webhook​