How to get a build status as part of the trigger execution API in NextGen

This document walks you through the steps to follow to get a build status as part of the trigger execution API in NextGen

  1. Create a custom webhook for a pipeline:


  2. Trigger your pipeline via a curl command.

  3. Example:

  • Request
curl -X POST \-H 'content-type: application/json' \--url 'https://app.harness.io/gateway/api/webhook/custom?accountIdentifier=<account_identifier>&orgIdentifier=<org_identifier>&projectIdentifier=<project_identifier>&pipelineIdentifier=<pipeline_identifier>&triggerIdentifier=<trigger_identifier>' \-d '{}' 
  • Response:
{  "status":"SUCCESS",  "data":"62e2f35160958b611e494564",  "metaData":null,  "correlationId":"b452749f-9cb7-484a-a755-ec494dae6071"}

The String returned in the data field is the “eventCorrelationId” for the trigger (“62e2f35160958b611e494564”).

  1. Query details about trigger processing and execution details for the triggered pipeline. The following command uses the “eventCorrelationId” returned above just after the “triggerExecutionDetails/” path.
curl -X GET \--url 'https://app.harness.io/gateway/pipeline/api/webhook/triggerExecutionDetails/62e2f35160958b611e494564?accountIdentifier=kmpySmUISimoRrJL6NL73w'
  • Response: The “data” field in the response will contain two fields:

A. “webhookProcessingDetails”: This is the data currently returned by /webhook/triggerExecutionDetails API.
B. “executionDetails”: This is the same data currently returned by the /pipelines/execution/v2/ API.

  1. Response Example:
{
  "status": "SUCCESS",
  "data": {
    "webhookProcessingDetails": {
      "eventFound": true,
      "eventId": "62eb058f11d58d120e940a5d",
      "accountIdentifier": "XXXXXXXX",
      "orgIdentifier": "XXXX",
      "projectIdentifier": "XXXXXXX",
      "triggerIdentifier": "XXXXX",
      "pipelineIdentifier": "XXXX",
      "pipelineExecutionId": "BOvtFC6xRReaPeJiOj2yvA",
      "exceptionOccured": false,
      "status": "TARGET_EXECUTION_REQUESTED",
      "message": "Pipeline execution was requested successfully",
      "payload": "{}",
      "eventCreatedAt": 1659569558794,
      "runtimeInput": "pipeline: {}\n"
    },
    "executionDetails": {
      "pipelineExecutionSummary": {
        "pipelineIdentifier": "test",
        "planExecutionId": "BOvtFC6xRReaPeJiOj2yvA",
        "name": "test",
        "status": "Expired",
        "tags": [],
        "executionTriggerInfo": { ... },
        "governanceMetadata": { ... },
        "moduleInfo": { ... }
        "layoutNodeMap": { ... },
        "modules": ["pms"],
        "startingNodeId": "Usu77wypQum1gB2hdur-8A",
        "startTs": 1659569558476,
        "endTs": 1659655962522,
        "createdAt": 1659569558663,
        "canRetry": true,
        "showRetryHistory": false,
        "runSequence": 9,
        "successfulStagesCount": 0,
        "runningStagesCount": 0,
        "failedStagesCount": 0,
        "totalStagesCount": 1,
        "executionInputConfigured": false,
        "allowStageExecutions": false,
        "stagesExecution": false
      }
    }
  },
  "metaData": null,
  "correlationId": "c793026a-a152-4377-ba97-b10d12f0df5d"
}

This is how we can get the build status as part of the trigger execution API in NextGen.

3 Likes