CI/CD Integrations

Overview

Continuous Integration and Continuous Delivery (CI/CD) tools aim to increase efficiency by forming a standardized testing and deployment process for your engineering teams.

Since correct tag implementation is often the responsibility of the development and/or QA team, it makes sense to put ObservePoint somewhere in that process. After working with many customers we have identified a few powerful use cases for ObservePoint integrations with CI/CD tools.

  • Kick off audits on a specific web site with a list of changed URLs
  • Kick off a list of audits and journeys at the time of regularly scheduled releases to catch implementation issues
  • Kick off audits and journeys during scheduled maintenance times in lower environments to prevent data loss
  • Use audit and journey rule failure notifications to create new JIRA tickets requesting implementation fixes

Since every team has a different testing and deployment workflow, whatever integration you build will likely be custom, but can still be guided by one of the use cases above.

Building out this integration should be a simple process for those familiar with CI/CD tools. The core of the integration is leveraging the ObservePoint API to start a list of pre-determined Audits and Journeys.

Below is a guide to help your quality assurance or devops team integrate ObservePoint with your development processes:

Trigger by ID

This example demonstrates how to use the API to start an Audit, Web Journey, or App Journey.

To make this call, you can use the following ObservePoint endpoint with a POST method:

https://api.observepoint.com/v2/cards/run

You will need a header with a key named “Authorization” with the value api_key {your api key here} which you can find here.

Finally, as this is a POST request you will need to attach a JSON payload to the request body. For this request, this will look like the following:

{"auditIds":[], "webJourneyIds":[], "appJourneyIds":[] }

For each of the empty arrays in the above payload, you can put IDs of the audits, journeys, or app journeys you would like to have started at the time of execution.

Here is an example of a JSON body for an API call that triggers 1 Audit and 1 Web Journey to run:

{"auditIds":[84672], "webJourneyIds":[19845], "appJourneyIds":[]}

Note: Not every parameter in the body is required. You can delete them or leave the arrays empty.

Here is another example where a JSON body in an API call triggers 2 App Journeys to run:

{"appJourneyIds":[22611,22610]}

To find the IDs to fill these arrays, you can simply go to the audit or journey you would like to have started and look at the URL. The ID is the first number you see:

https://app.observepoint.com/audit/123456/reports/summary/run/789123

Trigger by Folder

Note: This is an example of a script written in Javascript. It is likely that the teams that manage your CI/CD pipeline use a different programming language to trigger tests. This script is simple enough that they shouldn't have much difficulty translating it into the programming language they prefe

You will need to provide your ObservePoint folder Id(s) and API Key.

/*
THE 3 TRIGGER FUNCTIONS BELOW INITIATE THE OBSERVEPOINT SCANS IN THE THE ASSOCIATED FOLDERS

THE OTHER FUNCTIONS ASSIST IN THE OPERATION OF THE 3 TRIGGER FUNCTIONS AND MUST BE INCLUDED.
*/

let FolderId = 12345;

triggerTestsByFolder(FolderId); //trigger staging tests

function triggerTestsByFolder(folderId) {

  let apiKey = 'XXXXXXX';

  //get all audits
  let auditsEndpoint = '/web-audits'
  let auditsResponse = apiRequestGET(auditsEndpoint,apiKey);

  //get all journeys
  let journeysEndpoint = '/web-journeys'
  let journeysResponse = apiRequestGETv3(journeysEndpoint,apiKey);

  //filter out all audits/journeys that don't have folderId
  let filteredAudits = auditsResponse.filter(audit => {
    return audit.folderId == folderId;
  });

  let filteredJourneys = journeysResponse.filter(journey => {
    return journey.folderId == folderId;
  });
  
  //map to just the auditId/journeyId
  let auditIds = filteredAudits.map(audit => audit.id);
  let journeyIds = filteredJourneys.map(journey => journey.id);

  //make the api call
  let triggerEndpoint = '/cards/run';
  let triggerBody = {"auditIds": auditIds, "webJourneyIds": journeyIds};

  let response = apiRequestPOST(triggerEndpoint,apiKey,triggerBody);
  Logger.log(response);

}

//The functions below are helper functions and are required to run any of the above functions.
function apiRequestGET(endpoint,apiKey) {
  var url = 'https://api.observepoint.com/v2' + endpoint;
  var options = {
    'method': 'GET',
    'headers': {
      Authorization: 'api_key ' + apiKey
    },
    'contentType': 'application/json',
    'muteHttpExceptions': true
  }
  var ret = UrlFetchApp.fetch(url, options);
  return JSON.parse(ret);
                    
}

function apiRequestGETv3(endpoint,apiKey) {
  var url = 'https://api.observepoint.com/v3' + endpoint;
  var options = {
    'method': 'GET',
    'headers': {
      Authorization: 'api_key ' + apiKey
    },
    'contentType': 'application/json',
    'muteHttpExceptions': true
  }
  var ret = UrlFetchApp.fetch(url, options);
  return JSON.parse(ret);
                    
}

function apiRequestPOST(endpoint,apiKey, payload) {
  var url = 'https://api.observepoint.com/v3' + endpoint;
  var options = {
    'method': 'POST',
    'headers': {
      Authorization: 'api_key ' + apiKey
    },
    'payload': JSON.stringify(payload),
    'contentType': 'application/json',
    'muteHttpExceptions': true
  }
  var ret = UrlFetchApp.fetch(url, options);
  return JSON.parse(ret);
}
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.