Jenkins integration
  • 22 Sep 2022
  • 3 Minutes to read
  • Contributors
  • Dark
    Light

Jenkins integration

  • Dark
    Light

Article Summary

Autify provides the official Jenkins plugin to upload a build and run a test plan easily from your Jenkins workflow.

Getting started

This document describes how to use our Autify Jenkins plugin step-by-step.

Prerequisites

First, we assume you already have Jenkins Project or Pipeline to build your application. We'll add an Autify test step right after the build step to confirm the newly built application doesn't break the end-to-end experience.

Secondly, you need to create a test plan on Autify for Mobile. Please note the URL of your test plan e.g. https://mobile-app.autify.com/projects/AAA/test_plans/BBB and we'll use it later.

You also need to create a personal access token of Autify for Mobile. Please note the generated token somewhere so that we can store the value on Jenkins Secrets later.

Note: Since the personal access token is associated with a single user, we recommend you to create a machine user in your organization and use its personal access token for CI/CD integration.

Lastly, we currently only support Jenkins running on Linux or macOS platform. Windows is planned.

Install plugin

Open the Autify Plugin page and click "How to install" on the top right. You'll see the installation options like below:

Screen Shot 2022-08-12 at 9.46.25 AM.png

Store personal access token on Jenkins Secrets

Store the personal access token you generated above on Secrets by following Jenkins's document. Use "Secret text" for "Kind" and you can name an arbitrary "ID". Assuming you named it autifyMobileAccessToken here:

Screen Shot 2022-09-15 at 6.46.30 PM.png

Add a build step to upload a build and run Autify for Mobile

Finally, let's add a new step to your existing Jenkins Project or Pipeline.

Jenkins Project

Go to configuration of your Project and click "Add build step" under "Build" and select "Run test on Autify for Mobile":

Screen Shot 2022-09-15 at 7.56.45 PM.png

Then, select the ID of the Secret you created above e.g. autifyMobileAccessToken from the select box of "Personal Access Token of Autify for Mobile" and paste the URL noted above e.g. https://mobile-app.autify.com/projects/AAA/test_plans/BBB to "Autify for Mobile test URL".

See the examples below.


Upload a new build file and start a test (no waiting for the finish of the test):
Screen Shot 2022-09-15 at 6.47.50 PM.png

If you want to wait until the test finishes or timed out:
Screen Shot 2022-09-15 at 6.48.05 PM.png

To just upload a new build file, you can use "Upload build to Autify for Mobile" build step ("Workspace id" is the id right after /projects/ in the URL you noted above):

Screen Shot 2022-09-15 at 7.58.02 PM.png

Screen Shot 2022-09-15 at 7.57.47 PM.png

Jenkins Pipeline

Open your Jenkinsfile or Pipeline configuration page and insert the step below right after your deployment step.


Upload a new build file and start a test (no waiting for the finish of the test):

autifyMobile credentialsId: 'autifyMobileAccessToken', autifyUrl: 'https://mobile-app.autify.com/projects/AAA/test_plans/BBB', buildPath: 'path/to/your-[ios.app|android.apk]'

If you want to wait until the test finishes or timed out:

autifyMobile credentialsId: 'autifyMobileAccessToken', autifyUrl: 'https://mobile-app.autify.com/projects/AAA/test_plans/BBB', buildPath: 'path/to/your-[ios.app|android.apk]', wait: true

Just upload a new build file (workspaceId is the id right after /projects/ in the URL you noted above):

autifyMobileUpload credentialsId: 'autifyMobileAccessToken', workspaceId: 'AAA', buildPath: 'path/to/your-[ios.app|android.apk]'

(Not recommended) Using "Execute shell" step

If you don't want to use our Jenkins plugin or it has an issue, you can use "Execute shell" step instead.

Here is the summary of the process:

  1. Install the following plugins if you don't have yet:
  2. Store the personal access token as described above.
  3. Add "Execute shell" build step:
    • Jenkins Project:
      1. Add the Secret to "Build Environment" > "Bindings" (Use AUTIFY_MOBILE_ACCESS_TOKEN as "Variable")
      2. Add "Execute shell" build step e.g.:
      curl https://autify-cli-assets.s3.amazonaws.com/autify-cli/channels/stable/install-cicd.bash | bash -xe
      ./autify/bin/autify mobile test run https://mobile-app.autify.com/projects/AAA/test_plans/BBB --build-path path/to/your-[ios.app|android.apk]
      
    • Jenkins Pipeline:
      1. Add sh step surrounded by withCredentials e.g.:
      withCredentials([string(credentialsId: 'autifyMobileAccessToken', variable: 'AUTIFY_MOBILE_ACCESS_TOKEN')]) {
          sh '''
          curl https://autify-cli-assets.s3.amazonaws.com/autify-cli/channels/stable/install-cicd.bash | bash -xe
          ./autify/bin/autify mobile test run https://mobile-app.autify.com/projects/AAA/test_plans/BBB --build-path path/to/your-[ios.app|android.apk]
          '''
      }
      

Note: You can customize the Autify CLI command in the shell step as you like. See Autify CLI's documentation for more details.

Conclusion

By using Autify's Jenkins plugin (or shell step), you can automatically run a test plan or scenario after deployments so that you can detect regressions right away and take an appropriate actions without wasting time.


Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.