QTP/UFT – Jenkins & GitHub / SVN Integration

I get many comments from the readers to include a post on Jenkins-QTP-Source control integration & issues they are facing while trying to implement Jenkins-QTP console output which this post talks about. In this post, I would like to show how we can configure Jenkins to fetch the automated test scripts from the source control system like SVN/Github & showing the test case details in the Jenkins console. You can use any Source Control System like perforce. The idea is same. Ensure that you have Jenkins plugin is installed.

Sample QTP/UFT Script:

I am going to create a very simple QTP test script as shown below which launches a website in IE and check if an object is present or not. [I have uploaded the script in GitHub. You can download the script and play with it]

vsvn00

GitHub:

  • The above sample test scripts have been uploaded here.
  • I assume You already have Jenkins installed and a slave is configured.
  • Ensure that the Slave is configured with git. Download and install.
  • Lets create a simple and freestyle job in Jenkins.

vsvn04

  • Lets assume this job accepts some parameter from the user. Example: The environment of the application under test.  [Actually the sample script does not do anything with this parameter. I just wanted to show it is possible to pass a parameter].

vsvn05b

  • Select GitHub in the Source Code Management and update the URL as https://github.com/vinsguru/tag-qtp-jenkins-demo.git

vsvn10

  • Build section should have ‘Execute Windows batch command’ and the command should be ‘CScript runner.vbs %ENVIRONMENT%

vsvn06

  • Jenkins Job is ready to fetch the script from GitHub now. Click on Build to execute the scripts from Jenkins in the Slave machine.

vsvn08

  • Jenkins automatically downloads the script from github to the slave machine and executes it on the slave machine. [I assumed Slave has QTP installed].
  • It executes the script and shows the test case details being executed in the Jenkins console output and the status.

vsvn11

SVN:

You can also use Visual SVN Server which is FREE if you do not want to share your script in GitHub. 

  • Download and install from here.
  • Once installed, Create a Repository with default branches.

vsvn01

  • Create users and provide appropriate access. [For Jenkins, I create a separate user with readonly access]
  • Right click on the folder and copy the URL which you can access from any machine.

vsvn01b

vsvn02

  • VisualSVN Server is ready now which is up and running. We need a SVN client to push the script to the SVN server. We can use TortoiseSVN for this purpose.
  • Download and install TortoiseSVN from here.
  • Once installed, Create a folder – Right click – Do a SVN Checkout of the URL you have copied.
  • Copy all your test scripts under the folder – right click – Do SVN Commit.
  • This will push all your test scripts to the Visual SVN Server.

vsvn03

Jenkins-SVN Integration:

  • Select Subversion in the Source Code Management. Update the Repository URL to be checked out by Jenkins to run the script.
  • If it requires a credential, Add the Credentials. [If you do not see this, there is a Jenkins plugin. Install it in Jenkins]
  • Update the Check-out strategy as shown here.

 

vsvn04b

  • Credentials Plugin for Jenkins

vsvn05

  • Everything else will remain same. Click on Build to run the QTP script.

vsvn09

 

 

 

 

 

Happy Testing 🙂

 

Share This:

10 thoughts on “QTP/UFT – Jenkins & GitHub / SVN Integration

    1. i.e. Our automation tool is UFT and it is connected with HP-ALM.
      we want to have code versioning by using SVN so that we can have backup of code as well.

      Please let us know if this is feasible.

      Thanks,
      Sagar
      8885981431

    1. I have shared the code in GitHub. You can check yourself. It is basically responsible for showing the current test case execution details in the Jenkins console. Will be useful when you execute hundreds of tests in remote machine using jenkins. You will know what is happening in the remote machine immediately.

  1. given ssh for git Repository URL , below is the error thrown :

    Failed to connect to repository : Command “git ls-remote -h git@gitlab.spire2grow.com:Core/core-services-2.0.git HEAD” returned status code 128:
    stdout:
    stderr: Permission denied, please try again.
    Permission denied, please try again.
    Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
    fatal: Could not read from remote repository.

    Please make sure you have the correct access rights
    and the repository exists.

  2. Hi , I had qtp server , when I run the .bat script on cmd of that qtp server. it opens up the browser and does all the test. But when I run the same bat using jenkins, it writes everything on the console output of the build. Could you please help me with this.

  3. Great article, I have read your blog and I got very useful and knowledgeable information from your blog. You have done a great job.Good presentation thanks for the helpful blog.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.