A Continuous Integration Pipeline With Jennins in Docker

Setting up Jenkins and Docker 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:

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.

Sample of 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/

17 Easy Steps to Setup Jenkins Pipeline to Execute Provar Test

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).

Step 1: Ensure you have run the tests locally inside of the docker container.

Step 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.

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

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

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

How to add a project for your Jenkins and Docker Integration

Step 5: Click Ok to create the project and then select the Pipeline tab to navigate to the Pipeline section.

image shows creating the project and selecting the Pipeline tab to navigate to the Pipeline section.

Step 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.

Image shows a dropdown field menu when choosing a pipeline

Step 7: Change the SCM dropdown to match where your project is checked in.

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

Step 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.

Sample of adding Jenkins Credentials in your Jenkins pipeline for your Jenkins and Docker integration

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

Step 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.

Step 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.

Step 13: Here is the final Pipeline section once completed:

This is how final Pipeline appears when section once completed

Step 14: Click Save unless you would like to set any other Project properties first.

Step 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.

running a validation build on Jenkins for Provar project in Docker

Step 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.

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

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

ou should see a successful test run after checking test result

This article guide should be able to help you with your Jenkins and Docker Integration for your Provar projects.

Review Provar on G2

daviessatterign.blogspot.com

Source: https://www.provartesting.com/documentation/devops/continuous-integration/docker/setting-up-continuous-integration-with-jenkins-for-docker/

0 Response to "A Continuous Integration Pipeline With Jennins in Docker"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel