Skip to content

SDOSLabs/jenkins-pipeline-qa

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

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.

About

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

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages