Question
- The build configuration has a template attached.
- The template has artifact paths configured.
- The artifact paths in the build configuration were modified, which overrides the value inherited from the template.
- In the TeamCity UI > Build Configuration > Settings > General page, there is a Reset button near the Artifact paths field. Clicking this button resets the overridden value to the value inherited from the template.
Is there a way to imitate this artifact path reset behavior using the REST API?
Answer
There is no direct equivalent in the REST API for the artifact paths Reset button found in the UI.
However, it is possible to achieve the same results by using a PUT request to the build configuration's settings endpoint to directly modify the artifactRules value:
- Use
GET /app/rest/buildTypes/id:MyBuildConfigurationID/settingsto get the current settings. The example response, in XML format:<?xml version="1.0" encoding="UTF-8" standalone="yes"?><properties count="2" href="/app/rest/buildTypes/settings"><property name="artifactRules" value="logs/*.log"/><property name="buildNumberCounter" value="14"/></properties> - Use
PUT /app/rest/buildTypes/id:MyBuildConfigurationID/settingsto modify the settings. The body of the request should include all properties enclosed in<properties>...</properties>. - To reset the artifact paths to the value inherited from the template, the
artifactRulesproperty in the body should include theartifactRulesvalue from the template, along with theinherited="true"parameter. Example of the body of suchPUTrequest, in XML:<properties><property name="artifactRules" value="logs/*.log
logs/logs-subdir/*.log" inherited="true"/><property name="buildNumberCounter" value="14"/></properties>
Additional information
If the inheritance is not strictly required, there is an easier way to modify the artifact paths via API. See Modifying artifact paths of build configuration using REST API.
Comments
0 comments
Please sign in to leave a comment.