Creating a Build Template
Function
Creating a Build Template
Calling Method
For details, see Calling APIs.
URI
POST /v3/templates/create
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
X-Auth-Token |
Yes |
String |
User token. Obtain the value by calling the IAM service interface. (value of X-Subject-Token in the response header). Global tenant tokens are not supported. Use a region-level token whose scope is project. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
template |
Yes |
CreateTemplate object |
Build step template, which needs to be encapsulated in camel case. |
name |
Yes |
String |
Template Naming |
description |
No |
String |
Template Description |
tool_type |
No |
String |
Type |
parameters |
No |
Array of CreateBuildJobParameter objects |
List of build execution parameters |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
steps |
Yes |
Array of CreateTemplateSteps objects |
Build Execution Steps |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
properties |
No |
Map<String,Object> |
Specific Construction Procedure |
module_id |
Yes |
String |
Indicates the ID of the building module. |
name |
No |
String |
Building Module Name |
version |
No |
String |
Build version |
enable |
No |
Boolean |
Whether to enable this feature. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
name |
No |
String |
Parameter definition name. The default value is hudson.model.StringParameterDefinition. |
params |
No |
Array of CreateBuildJobParameterParam objects |
Subparameters of Construction Execution Parameters |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
name |
No |
String |
Parameter Field Name |
value |
No |
String |
Parameter Field Value |
limits |
No |
Array of LimitsParam objects |
Restrictions on Enumeration Parameters |
Response Parameters
Status code: 200
Parameter |
Type |
Description |
---|---|---|
result |
Object |
Template query result |
error |
String |
An error message is returned. |
status |
String |
Returned status information. |
Parameter |
Type |
Description |
---|---|---|
favourite |
Boolean |
Indicates whether to add a template to favorites. |
id |
String |
ID in the database. |
uuid |
String |
uuid |
template |
QueryTemplate object |
Build step template, which needs to be encapsulated in camel case. |
type |
String |
Template category. |
public |
Boolean |
Whether the Template Is Public |
name |
String |
Template Naming |
create_time |
String |
Created |
domain_id |
String |
domainId |
weight |
Double |
Weight |
user_id |
String |
User ID. |
user_name |
String |
User Name |
domain_name |
String |
Domain Name |
scope |
String |
Template scope. The default value is custom for a user-defined template. |
description |
String |
Template Description |
tool_type |
String |
Build tool type, which can be YAML build or action build. |
intl_description |
Object |
intl Description |
parameters |
Array of CreateBuildJobParameter objects |
List of build execution parameters |
i18n |
Object |
i18n |
Parameter |
Type |
Description |
---|---|---|
steps |
Array of CreateBuildJobSteps objects |
Build Execution Steps |
Parameter |
Type |
Description |
---|---|---|
properties |
Map<String,Object> |
Specific Construction Procedure |
module_id |
String |
Indicates the ID of the building module. |
name |
String |
Building Module Name |
version |
String |
Build version |
enable |
Boolean |
Whether to enable this feature. |
Parameter |
Type |
Description |
---|---|---|
name |
String |
Parameter definition name. The default value is hudson.model.StringParameterDefinition. |
params |
Array of CreateBuildJobParameterParam objects |
Subparameters of Construction Execution Parameters |
Parameter |
Type |
Description |
---|---|---|
name |
String |
Parameter Field Name |
value |
String |
Parameter Field Value |
limits |
Array of LimitsParam objects |
Restrictions on Enumeration Parameters |
Parameter |
Type |
Description |
---|---|---|
disable |
String |
Indicates whether the configuration takes effect. The default value is 0, indicating that the configuration takes effect. |
display_name |
String |
Name of a parameter. |
name |
String |
Parameter |
Status code: 400
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Error Codes |
error_msg |
String |
Description |
Status code: 401
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Error Codes |
error_msg |
String |
Description |
Status code: 403
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Error Codes |
error_msg |
String |
Description |
Status code: 404
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Error Codes |
error_msg |
String |
Description |
Status code: 500
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Error Codes |
error_msg |
String |
Description |
Example Requests
POST https://{endpoint}/v3/templates/create
Example Responses
Status code: 200
OK
{ "result" : { "public" : true, "favourite" : false, "id" : "6561b2ced7a6751941fdc8cd", "uuid" : "2d9031c079624376824fe1e2731615dc", "template" : { "steps" : [ { "properties" : { "image" : "maven3.5.3-jdk8-open", "snapshotArtifact" : { "displayName" : "", "value" : "" }, "userPrivateRepositories" : [ ], "deal" : "notDeal", "dependencyCheckParam" : " ", "userPublicRepositories" : [ ], "settingMode" : "auto", "doCheck" : "disable", "junitCoverageSwitch" : "false", "coverageReportPath" : "**/site/jacoco", "releaseArtifact" : { "displayName" : "", "value" : "" }, "cacheOption" : "cached", "command" : "# Function: packaging\nParameter description:\n#-Dmaven.test.skip=true: Skip the unit test.\n#-U: The dependency update is checked for each build. This avoids the problem that the snapshot version dependency in the cache is not updated, but some performance is affected.\n#-e -X: prints debugging information. You are advised to use this parameter to locate difficult build problems.\n#-B: Run in batch mode to avoid the ArrayIndexOutOfBoundsException exception during log printing.\n# Scenario: Used for packaging projects when unit tests are not required.\nmvn package -Dmaven.test.skip=true -U -e -X -B\n\n# Function: packaging; executing unit tests, but ignoring unit test case failures. Dependency updates are checked for each build.\n#Application scenario: Unit tests need to be executed, and the unit test report service provided by the build is used to collect statistics on the execution status.\n# Usage condition: Select Process Unit Test Result in Unit Test and enter the correct path of the test result file.\n#mvn package -Dmaven.test.failure.ignore=true -U -e -X -B\n\n# Function: Pack and release dependency packages to the private dependency library.\n#Application scenario: The build result of the current project needs to be released to the private dependency repository for other Maven projects to reference.\n#Note: The target repository to be uploaded is the CodeArts private dependency repository. Note that the target repository must be different from the software release repository.\n#mvn deploy -Dmaven.test.skip=true -U -e -X -B", "file" : "**/TEST*.xml", "dependencyProjectDir" : "./", "ignoreTest" : "false", "pomMode" : "no", "dependencySettings" : "~/.m2/settings.xml" }, "module_id" : "devcloud2018.codeci_action_20043.action", "name" : "Build with Maven", "version" : null, "enable" : true }, { "properties" : { "image" : "shell4.2.46-git1.8.3-zip6.00", "buildVersion" : "", "file" : "bin/*", "groupId" : "", "name" : "" }, "module_id" : "devcloud2018.codeci_action_20018.action", "name" : "Uploading Software Packages to Release Repos", "version" : null, "enable" : true } ] }, "type" : "codeci", "name" : "oych_test_temp_ladadad12122313", "create_time" : "2023-11-25T08:39:42.098+00:00", "domain_id" : "60021bab32fd450aa2cb89226f425e06", "weight" : 0, "user_id" : "ae22fd035f354cfa8d82a3f1c8940446", "user_name" : "devcloud_codeci_z00485259_02", "domain_name" : "devcloud_codeci_z00485259_02", "scope" : "custom", "description" : "123", "intl_description" : { }, "parameters" : [ { "name" : "hudson.model.StringParameterDefinition", "params" : [ { "name" : "name", "value" : "codeBranch", "limits" : null }, { "name" : "type", "value" : "normalparam", "limits" : null }, { "name" : "defaultValue", "value" : "master", "limits" : null }, { "name" : "description", "value" : "Code branch, which is a predefined parameter in the system.", "limits" : null }, { "name" : "deletion", "value" : "false", "limits" : null }, { "name" : "defaults", "value" : "true", "limits" : null }, { "name" : "staticVar", "value" : "false", "limits" : null }, { "name" : "sensitiveVar", "value" : "false", "limits" : null } ] } ], "i18n" : { } }, "error" : null, "status" : "success" }
Status Codes
Status Code |
Description |
---|---|
200 |
OK |
400 |
Bad Request |
401 |
Unauthorized |
403 |
Forbidden |
404 |
Not Found |
500 |
Internal Server Error |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.