Report results from a pipeline

The following flow demonstrates how to inject report results from a pipeline.

Entity relationship diagram

We need to access the following entities for this flow, and understand the relationships between these entities.

Entity relationship diagram for the CI Server and CI Job entities.

The following shows the relations in the flow.

Entity Relationships in this flow Description of relationship Reference / relationship fields
CI Server Pipeline Multiple pipelines can be defined for each CI server. pipeline
CI Job Pipeline Jobs are associated with pipelines. Each pipeline can contain one or more jobs. jobs
CI Job CI Build

Jobs are associated with builds. Each build can contain one or more jobs.

ci_job

Back to top

Flow

For details, see Add automated test results and Test results.

After authenticating, do the following:

  1. Register the CI/CD server.

    POST .../api/shared_spaces/<space_id>/workspaces/<workspace_id>/ci_servers
    {
       "data": [{
    	"name": "My_CICD_Server",                
    	"url": "http://<host>:<port>/<path>",                                
    	"server_type": "ci_server"   
       }]
    }
    
  2. Register a pipeline in the CI/CD server.

    POST .../api/shared_spaces/<space_id>/workspaces/<workspace_id>/pipelines
    {
       "data": [{
           "name": "Your pipeline name for display needs",    
    	"server_ci_id": "internal CI ID",
    	"root_job_ci_id": "internal CI ID", 
    	"jobs": [ 
    		{}, 
    		{},
    		…
    		],
    	
    }
    
    Field Description
    name Name of the pipeline for display purposes. Required, must be unique across the system (shared space).
    server_ci_id

    Internal ID for the server. Required.

    Prerequisite: A CI server with this name must exist already.

    root_job_ci_id Internal ID for the server's root job. Required.
    jobs

    A list of jobs. Required. At least one job, the root job, must be specified.

  3. Report build results.

    PUT .../api/shared_spaces/<space_id>/workspaces/<workspace_id>/analytics/ci/builds
    {
    	"serverCiId": "ci server instance id", 
    	"jobCiId": "job ci id",  
    	"buildCiId": "build_internal_ci_id", 
    	"buildName": "build display name, usually a number", 
    	"startTime": 1456679398786,   
    	"duration": 120490, 
    	"status": "finished", 
    	"result": "success",           
    	"parameters": […],  
    	"causes": [   
    		{…}, 
    		{…}
    		]
    }
    
Field Description
serverCiId ID for the server. Required.
jobCiId

ID for the job. Required.

buildCiId Internal ID for the build. Required.
buildName

Display name for the build, usually a number. Optional. If not supplied, the default is the buildCiId value.

startTime

The start time of the job. Required.

duration The duration for the job. Required.
status The status of the job. If not supplied, the default is finished.
result The result of the job. Required.
parameters List of parameters. Optional.
causes If not supplied the cause build is assumed to be the root build {…}, // .

Back to top

See also: