We're here to help

Setting up continuous integration with Jenkins

Setting up Continuous Integration for your Provar project is always recommended. This will help you in scheduling test runs, getting consistent reporting, and allowing you to execute test cases on a remote server. The following help page(s) can walk you through that process start to finish:

You can follow this help page to help you setup Jenkins for Provar using Jenkins Build Pipelines:

https://provartesting.com/help/devops/continuous-integration-tools/jenkins/setting-up-continuous-integration/

There is also another useful way of executing builds in Jenkins using declarative and/or scripted pipelines. These are pipelines that are created through a scripting language called Groovy. Here is an example Jenkinsfile that will accomplish the task of executing your Provar tests inside of the docker container generated by your Dockerfile.

 

Jenkins file

pipeline {

    agent {

        dockerfile true

    }

    stages {

        stage('Run Provar Tests') {

            steps {

                echo "Running ${env.BUILD_ID} on ${env.JENKINS_URL}"       

                sh "xvfb-run ant -f ANT/build.xml -v"

            }

        }

    }

    post {

        always {

            junit allowEmptyResults: true, testResults: 'ANT/Results/*.xml'

            cleanWs notFailBuild: true /* cleans up the workspace */

        }

        success {

            echo "Success: Good job!"

        }        

        failure {            

            echo 'Failure: Something went wrong with the Provar ANT build. Printing environment for debugging'            

            sh 'printenv'

            echo 'Printing hosts'

            sh 'cat /etc/hosts'

            echo 'Searching for provar directories/files in the system...'

            sh 'find / -name "provar*"'

            echo 'Finding chrome drivers'

            sh "find / -name '*chromedriver*'"

        }        

    }   

}

This Jenkinsfile assumes that your build.xml file is located in the ANT folder of your test project and is named ‘build.xml’. You can read more about them here:

https://jenkins.io/doc/book/pipeline/jenkinsfile/

Follow these steps to setup a Jenkins pipeline using a Jenkinsfile that executes your Provar tests inside of the docker container (assumes you have an accessible Jenkins instance that can communicate with your Version Control System).

(1) Ensure you have run the tests locally inside of the docker container.

(2) Make sure your Jenkinsfile and Dockerfile are both in the project’s root directory. If your Jenkinsfile is not in the root folder, remember to set the relative location of it in step 12.

(3) Check in your Provar test project into a Version Control System (VCS).

(4) On your Jenkins home page, select New Item to create a new project and then select Pipeline.

(5) Click ‘Ok’ to create the project and then select the Pipeline tab to navigate to the Pipeline section.

(6) Select the dropdown field and change to ‘Pipeline script from SCM’. You can also paste the Jenkinsfile into this block if you select ‘Pipeline script’. However, if you go down this road, you will need to add a step in the Jenkinsfile to pull your project files from your VCS/SCM.

(7) Change the SCM dropdown to match where your project is checked in.

(8) Enter the repository URL (with the .git ending if using Git SCM).

(9) You must also add credentials to your Jenkins instance in order to connect to this repository. Click the ‘Add’ dropdown and select Jenkins. You can authenticate this repository however you like; i.e. using a token or username/password. It is always recommended that you give the Credentials you save a recognizable ID and Description.

(10) Specify the branch you would like to access, if applicable (default is master for repository’s with a single branch).

(11) (Optional) In the Additional Behaviours section, select ‘Add’ and select ‘Clean before checkout’ and ‘Clean after checkout’. This will ensure you have a clean environment each time this project is built.

(12) Provide the relative path to your Jenkinsfile from the repository’s root directory. This will be ‘Jenkinsfile’ unless you did not place your Jenkinsfile in your project’s root and the repository structure does not reflect your Provar test project structure.

(13) Here is the final Pipeline section once completed:

(14) Click ‘Save’ unless you would like to set any other Project properties first.

(15) It is always a good idea to run a validation build on this project to ensure everything is working properly. Select ‘Build Now’ after saving.

(16) After a brief moment, you should see the project being building and can monitor its status by selecting the arrow by the build number and selecting ‘Console Output’.

(17) You should see a successful test run, assuming your tests are passing beforehand. Select ‘Test Result’ from the build view page.