All Collections
Integrations
CI/CD Integrations
CI/CD Integrations
Luiza Gircoveanu avatar
Written by Luiza Gircoveanu
Updated over a week ago

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 IDs

Audits

This example demonstrates how to use the API to trigger a batch of Audits.

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":[12345,54321,...]}

To find the IDs to fill these arrays, you can simply go to the Audit you would like to trigger and look at the URL. The ID is the first number you see:

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

A successful response will look like this, indicating no failures occurred when triggering Audits:

{failedToStartAudits=[], failedToStartAppJourneys=[]}

Journeys

This example demonstrates how to use the API to trigger Journeys.

Note: Triggering Journeys in batches is not supported, so you will need to loop through an array of Journey ids as show below.

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

https://api.observepoint.com/v3/web-journeys/12345/runs

Note: 12345 in this example is the Journey Id.

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 simply be an empty JSON object:

{}

To find the IDs to fill these arrays, you can simply go to the Journey you would like to trigger and look at the URL. The ID is the first number you see:

https://app.observepoint.com/web-journey/12345/run/59022494/results

A successful response will look like this, indicating a new run was initiated:

"newRunId": 59022494}

Trigger by Folder

Note: This is an example of a script written in Javascript (not node.js) which can be executed in a Google App Script. 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 prefer.

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

/*
THE TRIGGER FUNCTION BELOW INITIATES THE OBSERVEPOINT SCANS IN A GIVEN FOLDER

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

let FolderId = XXXXX;

triggerTestsByFolder(FolderId); //trigger staging tests

function triggerTestsByFolder(folderId) {

let apiKey = 'XXXXXXX';

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

//get all journeys
let journeysEndpoint = '/web-journeys'
let journeysResponse = apiRequestV3GET(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);

//to trigger all audits (batch method supported)
let triggerEndpoint = '/cards/run';
let triggerBody = {"auditIds": auditIds};
let response = apiRequestV2POST(triggerEndpoint,apiKey,triggerBody);
Logger.log(response);

//to trigger all journeys (loop method supported only)
journeyIds.forEach(journeyId => {
let journeyTriggerEndpoint = `/web-journeys/${journeyId}/runs`;
let journeyResponse = apiRequestV3POST(journeyTriggerEndpoint,apiKey,{});
Logger.log(journeyResponse);
});
}

//The functions below are helper functions and are required to run any of the above functions.
function apiRequestV2GET(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 apiRequestV3GET(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 apiRequestV3POST(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);
}

function apiRequestV2POST(endpoint,apiKey, payload) {
var url = 'https://api.observepoint.com/v2' + 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?