Reflect Docs

Connecting to CI/CD

Automatically execute Reflect tests from within your Continuous Integration/Continuous Deployment pipeline.

Via the Reflect API, you can automatically execute tests associated with a given tag (e.g. a ‘smoke-test’ tag). Below we’ve outlined how to trigger a Reflect API request from within several popular CI/CD tools.

Bitbucket Pipeline

To kick off Reflect tests as part of your pipeline, you’ll need to add an additional step in your existing bitbucket-pipelines.yml

pipelines:
  branches:
    master:
    ...
    - step:
      name: Regression Tests
      script:
      - curl -X POST --data "{\"sequential\": true }" -H "x-api-key: <API-KEY>" https://api.reflect.run/v1/tags/<TAG-SLUG>/execute

We recommend that you set up your Reflect API Key as a secure environment variable rather than including it directly in your bitbucket-pipelines.yml file.

For more information on setting up Bitbucket Pipeline, please consult Bitbucket’s online documentation.

CircleCI

To enable automated test execution, add an additional step in your CircleCI config.yml:

jobs:
  build:
    steps:
    ...
    - run:
      name: Regression Tests
      command: |
        curl -X POST --data "{\"sequential\": true }" -H "x-api-key: <API-KEY>" https://api.reflect.run/v1/tags/<TAG-SLUG>/execute

Your Reflect API key should be set outside of version control as an Environment Variable rather than hard-coded in your config.yml.

More information on calling REST APIs as part of a CircleCI build is available on the CircleCI blog.

GitHub Actions

Integrating with Github Actions

A request to the Reflect API can be triggered via the httpie.action Action.

workflow "Regression Tests" {
  on = "push"
  resolves = ["Call Reflect API"]
}

action "Call Reflect API" {
  uses = "swinton/httpie.action@<COMMIT-SHA>"
  args = ["POST", "https://api.reflect.run/v1/tags/<TAG-SLUG>/execute", "x-api-key:<API-KEY>", "sequential:=true"]
}
Integrating via Webhooks

Alternatively you can trigger Reflect tests by configuring a Webhook. For example, you can set up your Webhook to execute when a deployment status event with the value success is returned, meaning that a deployment of a git commit hash to a given environment has completed successfully.

For more information on configurating Webhooks, consult Github’s online documentation.

Gitlab CI/CD

A Reflect API request can be issued from your Gitlab CI/CD pipeline by modifying your existing .gitlab-ci.yml file:

regression_tests:
  stage: deploy
  script:
  - curl -X POST --data "{\"sequential\": true }" -H "x-api-key: <API-KEY>" https://api.reflect.run/v1/tags/<TAG-SLUG>/execute

The Reflect API key should be set as a predefined environment variable rather than hard-coded into the .gitlab-ci.yml.

For more information, check out Gitlab’s online documentation.

Jenkins Pipeline

A request to the Reflect API can be trigger via Jenkins Pipeline’s http_request plugin.

pipeline {
  stages {
    stage('Regression Test') {
      steps {
        ...
        script {
          httpRequest('https://api.reflect.run/v1/tags/<TAG-SLUG>/execute', customHeaders: [{name: 'x-api-key', value: 'API-KEY'}], requestBody: '{"sequential": true }')
        }
      }
    }
  }
}

For more information, please review the Jenkins Pipeline online documentation.

Copyright © 2020 Reflect Software LLC. All Rights Reserved.