Updated on 2024-05-08 GMT+08:00

Extension Properties

The following uses an example to describe the properties of an extension.

Extension Package

File structure:

extension.zip                          # ZIP package of the extension
   | -- scripts                        # (Optional) Script folder for storing scripts that contain extension execution logic.
   |    | -- xxx                       # Script that contains extension execution logic
   | -- i18n                           # (Optional) Contents in multiple languages
   |    | -- zh-cn                     # Contents in Chinese environment
   |         | -- resources.json       # Internationalization resources
   |    | -- en-us                     # Contents in English environment
   |         | -- resources.json       # Internationalization resources
   | -- codearts-extension.json        # (Mandatory) Extension execution file (in JSON format), including basic information, inputs, and execution

Notes:

  • The extension package must be in the ZIP format.
  • The root directory of the package must contain a metadata file codearts-extension.json.
  • During extension registration, set the Unique Identifier and Type fields to the values of name and category in the codearts-extension.json file, respectively.
  • The resources.json file can be encoded only using UTF-8.

    The mapping between the extension type and the value of category is listed in the following table.

    Type

    category

    Build

    Build

    Check

    Gate

    Deploy

    Deploy

    Test

    Test

    Normal

    Normal

codearts-extension.json

The following is an example of the file codearts-extension.json.

{
    "type": "Task",
	"name": "demo_plugin",
	"friendlyName": "Extension name",
	"description": "This is an extension.",
	"category": "Gate",
	"version": "0.0.2",
	"versionDescription": "Updated based on the initial version 0.0.1",
	"dataSourceBindings": [],
	"inputs": [{
	    "label": "URL for calling the service",
		"name": "SERVICE_URL",
		"type": "input",
		"description": "Enter a URL.",
		"defaultValue": "",
		"required": true
	},
	{
	    "label": "Token for calling the service",
		"name": "SERVICE_TOKEN",
		"type": "input",
		"description": "Enter a token.",
		"defaultValue": "",
		"required": true
	}],
	"execution": {
		"type": "Shell",
		"target": "scripts/execution.sh"
	},
	"outputs": []
}

The parameters are described in the following table.

Parameter

Description

type

The value is fixed to Task, which indicates an extension type.

name

Same as the Unique Identifier field set for extension registration

friendlyName

Same as the Name field set for extension registration

category

Same as the Type field set for extension registration, which can be:

  • Build: corresponds to the extension of the Build type.
  • Test: corresponds to the extension of the Test type.
  • Gate: corresponds to the extension of the Check type.
  • Normal: corresponds to the extension of the Normal type.
  • Deploy: corresponds to the extension of the Deploy type.

version

Version of the extension, which consists of three numbers separated by dots (.), with each number ranges from 0 to 99. Modify this parameter only when you need to add an official version.

description

Description of the extension.

versionDescription

Description of the extension version's unique features.

dataSourceBindings

Disabled currently. Set it to [].

inputs

Extension input content. This parameter corresponds to the extension display format on the pipeline page. The values can be referenced by environment variables in service scripts.

execution

Extension execution content. The type field indicates the service script language, and the target field indicates the path to the execution file. You are advised to create a scripts folder and place the content under it.

outputs

Extension output content. The value can be used as the gate metrics. output has different display.

inputs

The following is an example of inputs.

{
	"name": "samplestring",                              # Use ${samplestring} in a script to obtain the value configured by an executor in a pipeline
	"type": "input",                                     # Different types correspond to different functions
	"description": "Sample String",                      # Description of input
	"defaultValue": "00",                                # Default value when the value of the required field is false
	"required": true,                                    # Reset defaultValue if the required field is true, or the default value will be used
	"label": "Text box",                                # input information displayed on the pipeline editing page
	"validation": {
		"requiredMessage": "Enter a value.",                    # (Optional) The message displayed when the required field is left blank
		"regex": "^[a-zA-Z0-9-_\\u4e00-\\u9fa5]{1,32}$", # (Optional) RegEx validation
		"regexMessage": "Type error"                        # (Optional) The message displayed when RegEx validation failed
	}
}

For details about all inputs, see All inputs.