Git Product home page Git Product logo

jenkins-pipeline-qa's Introduction

jenkins-pipeline-qa

Project created by the QA department to provide a simple declarative pipeline to run your Appium Test using Jenkins in Android or iOS.


1. Requirements.

The parameters that you need to run this project are the following:

Define Global environment variables on Jenkins.

To be able to execute the pipeline in any system you have configured your Jenkins, you need to define several environment variables on the global configuration in Jenkins.

Fist, go to Manage Jenkins -> Configure System -> and on the Global properties section, add the following environment variables:

  • ANDROID_HOME: Directory where the Android SDK is located.
  • GIT_CREDENTIAL: Git API Access Tokens. This key is generated from the User Settings.
  • JOB_DIRECTORY: Directory where the Project Files are located.

Variables needed on the Initial Configuration.

Once we had this environment variables set, we need to define several variables inside the pipeline, some of them will use the environment variables we defined on Jenkins.

  • JOB_FILES_DIRECTORY: Directory where the Project Files are located. We will use the JOB_DIRECTORY environment variable defined on Jenkins.
  • PLATFORM_TOOL_DIRECTORY: Directory where the Platform Tools is located. We will use the ANDROID_HOME environment variable defined on Jenkins.
  • EMULATOR_DIRECTORY: Directory where the Android Emulator is located. We will use the ANDROID_HOME environment variable defined on Jenkins.
  • SUITE_PATH: Path of the Suite to execute

Variables needed on the Job Configuration.

When we created a new job in Jenkins to execute our Appium Test using this pipeline, we need to create several parameters needed for the test to run. To define this set of parameter, we need to create a new job in Jenkins, and, on the General section, click on the option: "This project is parameterized". The parameters we need to create are:

  • JOB_GIT_URL: Code Repository URL of the Automated Test. String parameter.
  • JOB_GIT_BRANCH: Branch to download the code from. String parameter.
  • JOB_APP_NAME: Application Name to launch on the emulator. If the default value is empty, the app to test will be the one you set on the POM.xml. String parameter.
  • JOB_DEVICE_NAME: Emulator (already created on your system) to launch. Choice parameter.
  • JOB_EMULATOR_PLATFORM_VERSION: Emulator Version needed for the Appium Test to run (Appium Capability). Choice parameter.
  • JOB_PLATFORM_NAME: Device Platform Name to launch the test: android or ios. String parameter
  • JOB_APPIUM_SUITE: Name of the Test Suite to execute. Choice parameter.
  • JOB_SLACK_CHANNEL_NOTIFICATION: Name of the Slack channel (you need to use Slack on your company and have a custom team domain) to notify the result of the job execution. You need to previously configure Slack on the Manage Jenkins -> Configure System -> Global Slack Notifier Settings section in order to use it. String parameter.

These parameters are the needed capabilities to be able to run the Appium Test along with the Appium Core of SDOS.

Once you have all the parameters needed on your job, you just need to add on the Pipeline section, the URL of this repository and set the Script Path to the Jenkinsfile on this repository.

2. Stages.

  • 1. Initial Configuration: Stage to set the configuration we needed to run the test. Set several variables such as JOB_FILES_DIRECTORY or the SUITE_PATH. Also we clean the workspace before start.
  • 2. Download GIT Code: Stage to download the code from your repository using the JOB_GIT_URL and JOB_GIT_BRANCH parameters you set on Jenkins.
  • 3. Execute ADB Server: This stage is executed only if the JOB_PLATFORM_NAME parameter is Android. On this stage, we start the ADB server.
  • 4. Launch Android Emulator: This stage is executed only if the JOB_PLATFORM_NAME parameter is Android. On this stage, we launch the emulator we set on the JOB_DEVICE_NAME on Jenkins. The emulator should be created before execute this pipeline.
  • 5. Run Appium Test: On this stage, we run the Appium test with the configuration we set on the Jenkins parameters. First, the pipeline check if the app name is defined (JOB_APP_NAME) or not on the Jenkins parameter. If the JOB_APP_NAME is not set, the app to execute should be defined on the POM.xml. If the execution is success, we published the result using Junit Report Plugin, if the execution is not success (failed or unstable), we archive the screenshot of the failed test and then publish the execution test result using Junit Report Plugin.
  • 6. SonarQube: This stage use a Sonar Server configuration. In order to be able to see your Sonar analysis result, you need to configure your Sonar Server on: Manage Jenkins -> Configure System -> SonarQube servers section.
  • 7. Post Build actions: On this stage, the build execution result will be published on the Slack channel you defined on JOB_SLACK_CHANNEL_NOTIFICATION with a specific message of the execution result.

3. More Information.

If you want to read more information about declarative pipelines and our way to integrate it on Jenkins, you can read the following article published on the SDOS Blog: https://sdos.es/integracion-continua-pasa-por-pipelines/


This project is licensed under the terms of the Apache license.

jenkins-pipeline-qa's People

Contributors

estefafdez avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.