Help Center> CodeArts Pipeline> User Guide> Extensions> Custom Extensions> Developing Extensions Using Low Code
Updated on 2024-05-08 GMT+08:00

Developing Extensions Using Low Code

When registering an extension or creating an extension version, you can use shell commands to implement service logic. The commands usually involve interaction with all kinds of data during pipeline execution. This section describes how to develop extension code through data input and output.

Data Input

The obtained data consists of low-code GUI input, pipeline run parameters, and other information.

  • Low-code GUI input: Obtain the low-code user interface output by using environment variables, for example, echo ${Widget ID}.
  • Pipeline run parameters: Some pipeline run parameters will be delivered to environment variables as shown in the following table.

    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

    Job ID of the pipeline.

  • Other information: Obtain information by interacting with external data through Git, Wget, and Curl.

Data Output

Once executed, the custom extension can read file information in a specified path and obtain the metric data output.

  1. On the configuration page, drag the Metrics widget to configure the output threshold of the extension.
  2. During development, the ${STEP_ID}_result.json and ${STEP_ID}_metrics.json files are stored in a specified path so that metric values can be parsed.
    Table 1 Output files

    File

    Description

    ${RESULT_MSG_PATH}/${STEP_ID}_result.json

    The output is a text file in {"par1":123, "par2":456} format. After the pipeline is executed, the result will be displayed as the corresponding task result.

    NOTE:

    Only extensions of the check type can display the result.

    ${RESULT_MSG_PATH}/${STEP_ID}_metrics.json

    The output is a text file in {"par1":123, "par2":456} format. The Metrics widget should be configured. After the extension is executed, the threshold configured for the Metrics widget and the content of ${STEP_ID}_metrics.json are parsed for pipeline pass conditions. Note:

    • During parsing, empty key values in the Metrics widget will be ignored.
    • If the key value configured for the Metrics widget cannot be found in the ${STEP_ID}_result.json file, the specified threshold value will be used.

    Example: par1 and par2 for pass conditions; par3 and par4 for task result display. The sample code is as follows:

    # Optionally, construct the extension output.
    echo '{"par1":100,"par2":200}' > ${RESULT_MSG_PATH}/${STEP_ID}_result.json
    echo '{"par3":300,"par4":400}' > ${RESULT_MSG_PATH}/${STEP_ID}_metrics.json
  3. After the extension run is complete, click the extension card to view the output.

    If policies are configured for the current extension and applied to the pipeline pass conditions, click the pass conditions to view the check status.