View all methods

pipelineJobs.upsert

Insert or update a job (or stage) within a pipeline run, such as a test, lint, or build step.

Facts

Method POST https://yourinstance.getdx.net/api/pipelineJobs.upsert

Arguments

Required arguments

Name Type Description
token Token Auth token passed as an HTTP header.
pipeline_source Text The same source name used when creating the run with pipelineRuns.upsert.

Example:
Tekton
run_reference_id Text The reference_id of the pipeline run this job belongs to. The run must already exist and must have been created with pipelineRuns.upsert.

Example:
AA713E04-1880-4E17-8C49-4A41733DAFCF
reference_id Text An identifier for this job, unique within the run. Sending the same value again updates the existing job.

Example:
unit-tests
name Text Name of the job or stage.

Example:
Unit tests
status Text One of success, failure, cancelled, running, or unknown.

Optional arguments

Name Type Description
started_at ISO-8601 Timestamp for when the job started.

Example:
2025-01-01T12:05:00
finished_at ISO-8601 Timestamp for when the job finished. When both timestamps are provided, the duration is calculated for you.

Example:
2025-01-01T12:10:00

Usage info

Use this method alongside pipelineRuns.upsert when you want job-level or stage-level detail, for example to track which tests passed or failed, or to capture pipelines that don’t deploy anything.

  1. Create the run with pipelineRuns.upsert.
  2. Send a request to pipelineJobs.upsert for each job or stage. You can send one request when a job starts and another when it finishes. Requests with the same run_reference_id and reference_id update the same job.

DX stores jobs in the same way as jobs imported from native connectors such as GitHub Actions. Only success and failure are recorded as final outcomes. cancelled, running, and unknown are recorded as not finished.

A job that has finished (success or failure) is never reopened. A later running, cancelled, or unknown update keeps the final status, but any started_at or finished_at you send is still applied, and the duration is recalculated from the stored timestamps. If such an update contains nothing that can be applied, the request fails with job_already_finished. A success can still be corrected to failure, and the reverse.

Jobs can only be added to runs created through pipelineRuns.upsert, not to runs imported by a native connector.

Example request

curl -X POST https://yourinstance.getdx.net/api/pipelineJobs.upsert \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer xxxx-xxxxxxxxx-xxxx" \
  -d '{
  "pipeline_source": "Tekton",
  "run_reference_id": "AA713E04-1880-4E17-8C49-4A41733DAFCF",
  "reference_id": "unit-tests",
  "name": "Unit tests",
  "status": "failure",
  "started_at": "2025-01-01T12:05:00",
  "finished_at": "2025-01-01T12:06:00"
  }'

Errors

This table lists the expected errors that this method could return. However, other errors can be returned in the case where the service is down or other unexpected factors affect processing. Callers should always check the value of the ok param in the response.

Error Code Description
not_authed This error occurs if the API request does not include a valid API key for authentication.
invalid_auth The provided API key is invalid. This can happen if the key is expired or does not exist.
invalid_json The JSON body of the request could not be parsed. This usually indicates a syntax error.
invalid_timestamp The started_at or finished_at format was not a readable ISO-8601 date format.
invalid_status status was not one of success, failure, cancelled, running, or unknown.
pipeline_run_not_found No run created through pipelineRuns.upsert matches pipeline_source and run_reference_id.
job_already_finished HTTP 409. The job already has a final status and the request had no timestamps to apply.
lock_timeout HTTP 409. Another request for the same job was in progress. Retry the request.
required_params_missing One or more required parameters were not provided in the request.