# Azure Pipeline

Source: https://help.testapp.io/azure-pipeline/

Azure Pipeline allows you to build and upload both Android and iOS apps to TestApp.io for testing and feedback. Here's how to do it:

## iOS

To integrate TestApp.io with Azure Pipeline for iOS, follow these steps:

### 1. Clone the sample project testappio-ios-sample-app from GitHub and switch to the integration-azure branch:

```bash
git clone https://github.com/testappio/ios-sample-app.git
git checkout integration-azure
```

### 2. Configure the iOS project for Fastlane:

- [Install Fastlane](https://docs.fastlane.tools/getting-started/ios/setup/).
- Create a `./Gemfile` file in the root directory of your project with the following content:

```bash
source "https://rubygems.org"
gem "fastlane"
```

- Run `bundle update` and add both the `./Gemfile` and the `./Gemfile.lock` files to version control.
- Initiate Fastlane by running the following command in the iOS project folder:

```bash
bundle exec fastlane init
```

- Follow the wizard; it will create a `./fastlane/Appfile` file with your Apple ID and team.
- Initiate Match by running the following command:

```bash
bundle exec fastlane match init
```

- Follow the instructions and provide the new empty git repository when asked; it will create the Matchfile.

> ⚠️ ****Note****: Please use the HTTPS GIT repository address.

- Generate the certificate and provisioning profile by running the following command:

```bash
bundle exec fastlane match adhoc
```

- Provide a matching password for encrypting the certificates and profiles in the GIT repository.

> ⚠️ ****Note****: Provide a matching password for encrypting the certificates and profiles in the GIT repository.

- Add the `testappio` plugin for Fastlane by running the following command:

```bash
bundle exec fastlane add_plugin testappio
```

### 3. Select provisioning profiles in Xcode:

The newly created certificates and profiles should now be possible to select inside your project. Open Xcode and go to `Signing & Capabilities`.

> ⚠️ Note: Don't choose Automatically manage signing

### 4. Set up Azure Pipeline:

- Create an Azure Pipeline and select the pipeline configuration file created in the previous step.
![Screenshot-2023-03-04-at-19.43.21_o](https://f000.backblazeb2.com/file/help-testappio/2023/03/Screenshot-2023-03-04-at-19.43.21_o.png)
- Configure `MATCH_PASSWORD` secret variable for the pipeline.
![Screenshot-2023-03-04-at-19.46.08_o](https://f000.backblazeb2.com/file/help-testappio/2023/03/Screenshot-2023-03-04-at-19.46.08_o.png)
- Similarly, configure `GITHUB_API_TOKEN` the secret variable for the pipeline by navigating to [Tokens](https://github.com/settings/tokens) and generating a Personal Access Token.
- Add `TESTAPPIO_API_TOKEN` and `TESTAPPIO_APP_ID` as secret variables for the TestApp.io Fastlane plugin. You can grab the API token from [Profile -> API Tokens](https://portal.testapp.io/profile/tokens) and the App ID from your [App -> Integrations](https://portal.testapp.io/apps).
[Find your API token](https://portal.testapp.io/profile/tokens)

### 5. Create the lane:

Create a `./fastlane/Fastfile` file and copy the following content:

```bash
default_platform(:ios)

platform :ios do
  desc "Build the adhoc and upload to TestApp.io"
  lane :beta do
    match(type: "adhoc")
    gym(export_method: "ad-hoc")
    upload_to_testappio(
      release_notes: "My release notes here...",
      git_release_notes: true,
      git_commit_id: false,
      notify: true
    )
  end
end
```

More info on the Fastlane plugin: [https://help.testapp.io/fastlane-plugin/#usage](https://help.testapp.io/fastlane-plugin/#usage)

Note that you may already have your lane in place. Copy the `upload_to_testappio` action and put it into your pipeline after the IPA export.

Here's the Azure Pipeline configuration file:

```bash
trigger:
- main

pool:
  vmImage: macOS-12

steps:
- script: |
    bundle install
    bundle exec fastlane ios beta
  displayName: 'Execute the lane'
```

### 6. Commit and push the change to trigger the pipeline.

---

## Android

To integrate TestApp.io with Azure Pipeline for Android, follow these steps:

### 1. Clone the sample project android-sample-app from GitHub and switch to the integration-azure branch:

```bash
git clone https://github.com/testappio/android-sample-app.git
git checkout integration-azure
```

### 2. Configure the Android project

- [Install Fastlane](https://docs.fastlane.tools/getting-started/ios/setup/).
- Create a `./Gemfile` file in the root directory of your project with the following content:

```bash
source "https://rubygems.org"
gem "fastlane"
```

- Run `bundle update` and add both the `./Gemfile` and the `./Gemfile.lock` files to version control.
- Initiate Fastlane by running the following command in the Android project folder:

```bash
bundle exec fastlane init
```

- Follow the wizard; it will create a `./fastlane/Appfile` file with the required information.

### 3. Set up Azure Pipeline:

- Add `TESTAPPIO_API_TOKEN` and `TESTAPPIO_APP_ID` as secret variables for the TestApp.io Fastlane plugin. You can grab the API token from [Profile -> API Tokens](https://portal.testapp.io/profile/tokens) and the App ID from your [App -> Integrations](https://portal.testapp.io/apps).
[Find your API token](https://portal.testapp.io/profile/tokens)

### 4. Create the lane:

Create a `./fastlane/Fastfile` file and copy the following content:

```bash
default_platform(:android)

platform :android do
  desc "Build and upload to TestApp.io"
  lane :beta do
    gradle(
      task: "assemble",
      build_type: "Release"
    )
    upload_to_testappio(
      release_notes: "My release notes here...",
      git_release_notes: true,
      git_commit_id: false,
      notify: true
    )
  end
end
```

More info on the Fastlane plugin: [https://help.testapp.io/fastlane-plugin/#usage](https://help.testapp.io/fastlane-plugin/#usage)

Note that you may already have your lane in place. Copy the `upload_to_testappio` action and put it into your pipeline after the APK export.

Here's the Azure Pipeline configuration file:

```yaml
trigger:
- main

pool:
  vmImage: ubuntu-22.04

steps:
- script: |
    bundle install
    bundle exec fastlane android beta
  displayName: 'Execute the lane'
```

### 5. Commit and push the change to trigger the pipeline.

That's it! Now you can build and upload your Android and iOS apps to TestApp.io for testing and feedback using Azure Pipeline.

---

#### Related Setup Guides

- [Setup iOS Project for Fastlane](https://help.testapp.io/setup-ios-project-for-fastlane/)

> **Tip:** Once your CI/CD pipeline uploads a build, team members using the [TestApp.io mobile app](https://help.testapp.io/mobile-app-getting-started/) receive a push notification and can install the build with a single tap. You can also create [share links](https://help.testapp.io/how-to-share/) to distribute builds to external testers and clients.

---

Need help? [Contact us](https://testapp.io/contact-us/). we're happy to assist!
