Developing Extensions Using Low Code
When registering an extension or creating an extension version, you can enter shell commands to implement service logic, which usually involves interaction with all kinds of data during pipeline execution. This section describes the code implementation of extension development through input and output.
Data Input of Custom Extensions
The information obtained during extension development mainly consists of three parts: low-code GUI input, pipeline running parameters and other information.
- Low-code GUI input: Obtain the low-code GUI output through environment variables, for example, echo ${Control ID}.
- Pipeline running parameters: Some pipeline running parameters are delivered to environment variables. Currently supported environment variables are listed as follows:
Variable
Description
STEP_NAME
Step name of the pipeline.
STEP_ID
Step ID of the pipeline.
PLUGIN_VERSION
Version of the extension.
PIPELINE_ID
Pipeline ID.
PIPELINE_RUN_ID
Pipeline execution ID.
PLUGIN_NAME
Extension name.
PROJECT_ID
Project ID.
JOB_ID
Task ID of the pipeline.
- Other information is obtained from the interaction with external data through git, wget, and curl.
Data Output of Custom Extensions
Once executed, the custom extension can read file information in a specified path and obtain the metric data output.
- On the low-code GUI, drag the metrics widget to configure the output threshold of the extension.
- During development, the ${STEP_ID}_result.json and ${STEP_ID}_metrics.json files are exported to the specified path so that metric values can be parsed after the extension is executed.
Table 1 Output files File
Description
/var/devcloud/workspace/temp-mnt/result/${STEP_ID}_result.json
The output is a text file in {"par1":123, "par2":456} format. After the pipeline is executed, the result is displayed as the corresponding task result.
NOTE:Only check extensions can display the result.
/var/devcloud/workspace/temp-mnt/result/${STEP_ID}_metrics.json
The output is a text file in {"par1":123, "par2":456} format. The metrics control is also used. After the extension is executed, the threshold of the metrics control and the actual file content ${STEP_ID}_metrics.json are parsed and compared for pipeline exit. Precautions:
- During parsing, empty key values will be ignored.
- If the corresponding key value cannot be found in the ${STEP_ID}_result.json file, the specified threshold value is used.
Example: par1 and par2 metrics for exit interception and par3 and par4 for task result display. The sample code is as follows:
# Optionally, construct the extension output. echo '{"par1":100,"par2":200}' > /var/devcloud/workspace/temp-mnt/result/${STEP_ID}_metrics.json echo '{"par3":300,"par4":400}' > /var/devcloud/workspace/temp-mnt/result/${STEP_ID}_result.json
- After the extension is run, click the corresponding step card to view the output.
If a policy is configured for the current extension and applied to the pipeline pass condition, click the pass condition to view the interception.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.