Pipeline Contexts
Contexts are a way to access information about pipeline runs, sources, variables, and jobs. Each context is an object that contains various attributes. The following table lists pipeline contexts.
| Context | Type | Description |
|---|---|---|
| pipeline | object | Information about the pipeline run. |
| sources | object | Information about the pipeline sources in each pipeline run. |
| env | object | Information about the custom parameters in each pipeline run. |
| jobs | object | Information about jobs that have reached the final states in each pipeline run. |
Context Reference Format
${{ <context>.<attribute_name> }} context indicates the pipeline context, attribute_name indicates the attribute.
Contexts Attributes
| Context | Attribute | Type | Description | Example |
|---|---|---|---|---|
| pipeline context | pipeline | object | Information about the pipeline run. This object contains the following attributes: project_id, pipeline_id, run_number, timestamp, trigger_type, and run_id. |
|
| pipeline.project_id | string | ID of the project to which the current pipeline belongs. This string is the same as the predefined parameter PROJECT_ID. | ||
| pipeline.pipeline_id | string | Current pipeline ID. This string is the same as the predefined parameter PIPELINE_ID. | ||
| pipeline.run_number | string | Pipeline execution number. This string is the same as the predefined parameter PIPELINE_NUMBER. | ||
| pipeline.timestamp | string | Pipeline execution timestamp. This string is the same as the predefined parameter TIMESTAMP. The format is yyyyMMddHHmmss. For example, 20211222124301. | ||
| pipeline.trigger_type | string | Pipeline triggering type. This string is the same as the predefined parameter PIPELINE_TRIGGER_TYPE. | ||
| pipeline.run_id | string | Pipeline execution ID. This string is the same as the predefined parameter PIPELINE_RUN_ID. | ||
| sources context | sources | object | Information about the pipeline sources in each pipeline run. This object contains the following attributes: alias, repo_name, commit_id, commit_id_short, commit_message, repo_url, repo_type, repo_name, ssh_repo_url, tag, merge_id, source_branch, and target_branch. |
|
| sources.<alias> | object | Information about the pipeline source which has an alias. | ||
| sources.<repo_name> | object | Information about the pipeline source which does not have an alias but only a repository name. It contains the same information as that in sources.<alias>. | ||
| sources.<alias>.commit_id | string | The last commit ID before execution. This string is the same as the predefined parameter COMMIT_ID. | ||
| sources.<alias>.commit_id_short | string | The first 8 characters of the last commit ID before execution. This string is the same as the predefined parameter COMMIT_ID_SHORT. | ||
| sources.<alias>.commit_message | string | The commit information from the last code commit before the pipeline execution. | ||
| sources.<alias>.repo_url | string | Code repository address (HTTPS). This string is the same as the predefined parameter REPO_URL. | ||
| sources.<alias>.repo_type | string | Type of the code repository. For example, codehub, gitlab, github, gitee, and general_git. | ||
| sources.<alias>.repo_name | string | Name of the code repository. | ||
| sources.<alias>.ssh_repo_url | string | Code repository address (SSH). | ||
| sources.<alias>.tag | string | Tag name when the tag is triggered. | ||
| sources.<alias>.merge_id | string | Merge request ID when the merge request is triggered. | ||
| sources.<alias>.source_branch | string | Source branch name when the merge request is triggered. | ||
| sources.<alias>.target_branch | string | If the merge request is triggered, this string indicates the name of the target branch. Otherwise, this string indicates the name of the running branch. | ||
| env context | name | string | Name of a custom parameter. | |
| value | string | Value of a custom parameter. | ||
| jobs context | jobs | object | Information about jobs in a pipeline. This object contains the following attributes: job_id, status, outputs, output_name, metrics, and metric_name. |
|
| jobs.<job_id> | object | Information about the job with a specified ID. | ||
| jobs.<job_id>.status | string | Job execution result. The value can be INIT, QUEUED, RUNNING, CANCELED, COMPLETED, FAILED, PAUSED, IGNORED, SUSPEND, or UNSELECTED. | ||
| jobs.<job_id>.outputs | object | The running value, as a key-value pair. | ||
| jobs.<job_id>.outputs.<output_name> | string | The running value name. | ||
| jobs.<job_id>.metrics | object | The running metrics of a job. For example, the number of code check issues and the test pass rate. | ||
| jobs.<job_id>.metrics.<metric_name> | string | The running metric name of a job. |
Related Information
The following are context scenarios:
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.