Jump to Section
    Sep 06 2018

    Kobiton - Jenkins Integration

    What Is Continuous Integration

    • Continuous Integration (CI) is a development practice that requires developers to integrate code into a shared repository several times a day. Each check-in is then verified by an automated build, allowing teams to detect problems early.

    Jenkins, the leading open source automation server, Jenkins provides hundreds of plugins to support building, deploying and automating any project. It is written in the Java programming language for testing and reporting on isolated changes in a large code base in real time. The software enables developers to find and solve defects in a code base rapidly and to automate testing of their builds.

    Prerequisites

    • CI tool is installed and set up properly. In this example, we will use Jenkins, which is a popular CI and easy to integrate with.
    • NodeJS is installed from your Mac or installed through Jenkins Plugin Manager.

    Configuration Steps

    1. Create a New item in Jenkins
    2. Enter job name (e.g "Kobiton Jenkins Integration Tests"), and then choose "Pipeline"
    3. Select "Configure" for "Kobiton Jenkins Integration Tests" job
    4. Check "
      1. Add String Parameter KOBITON_USERNAME and enter your name as the default value
      2. Add String Parameter KOBITON_API_KEY and enter your apiKey as the default value
    5.  In the Pipeline part, we choose pipeline script
    6. Copy the script below and paste into Pipeline script
    import groovy.transform.Field
    
    node('master') {
      withEnv(["PATH+NODE_JS=/usr/local/bin/"]) {
        stage('Prepare environment') {
          sh("node -v")
          git banch: 'master', url: 'https://github.com/kobiton/samples.git'
          retry(3) {
            sh 'cd javascript && rm -fr node_modules && npm install'
          }
        }
        stage('Run test') {
          sh('cd javascript && npm run android-app-test')
          sh('cd javascript && npm run ios-app-test')
          sh('cd javascript && npm run android-web-test')
          sh('cd javascript && npm run ios-web-test')
          }
      }
    }

    Explanation:

    • We will use Kobiton Samples at https://github.com/kobiton/samples.git to integration with Jenkins Pipeline.
    • It will fetch the source code from Github and install node_modules at your Mac
    • We will have 4 test cases and run with NodeJS language
      • Execute Android web testing
      • Execute iOS web testing
      • Execute Android app testing
      • Execute iOS app testing

    Execution

    • Select "Build with Parameters"
    • Then, click the Build button

    Reports

    • We can view the result through Jenkins Console Output
      • Select the latest build in Build History
      • Select Console Output
    • Or access https://portal.kobiton.com/sessions to get your test sessions