Skip to main content

Define branch configuration for a repository

Learn how to use the Repository Settings API to define branch configuration for a repository.

All sample requests in this guide include the following path parameters:

Parameter nameDescription
tenantIdYour tenant ID.
starSystemIdID of a star system that includes the repository for which you modify the branch configuration.
repositoryNameName of a repository. See supported repositories.

About branch configuration

To customize branch configuration for a repository, you can do the following:

  • Enable or disable selected branch types.
  • Specify a prefix for each branch type.

For example, you can use the dedicated branches for development in parallel to your main codebase and without affecting it.

important

You can't use the Repository Settings API to change the branching strategy defined by Guidewire Cloud Standards.

Default configuration

Branch configuration is defined on the project (star system) level and, by default, inherited by each repository. You can customize this configuration separately for each repository in your star system.

note

You can't modify a project (star system) level configuration with the Repository Settings API.


Get configuration

To retrieve branch configuration for a repository, send the following GET request:

curl -X 'GET' \
'{baseUrl}/api/v1/tenants/{tenantId}/starsystems/{starSystemId}/repository/{repositoryName}/branch-configuration' \
-H 'accept: application/json' \
-H 'Authorization: Bearer {access_token}'

Response contains a JSON object with current branch configuration for the specified repository.

Example response
{
"development": {
"refId": null,
"useDefault": true
},
"production": {
"refId": "refs/heads/master",
"useDefault": false
},
"prefixes": {
"bugfix": {
"enabled": true,
"prefix": "bugfix/"
},
"feature": {
"enabled": false,
"prefix": "feature/"
},
"hotfix": {
"enabled": true,
"prefix": "hotfix/"
},
"release": {
"enabled": false,
"prefix": "release/"
}
},
"scope": {
"type": "REPOSITORY"
}
}

Modify branch configuration

To modify branch configuration for a repository, send the following PUT request:

curl -X 'PUT' \
'{baseUrl}/api/v1/tenants/{tenantId}/starsystems/{starSystemId}/repository/{repositoryName}/branch-configuration' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer {access_token}' \
-H 'Content-Type: application/json' \
-d '{body}'

Where {body} contains the updated configuration.

For example, to use custom development and production branches and specify the bugfix and hotfix prefixes, use the following:

Request body
{
"development": {
"refId": "refs/heads/master",
"useDefault": false
},
"production": {
"refId": "refs/heads/master",
"useDefault": false
},
"prefixes": {
"bugfix": {
"prefix": "bugfix/",
"enabled": true
},
"feature": {
"prefix": "feature/",
"enabled": false
},
"hotfix": {
"prefix": "hotfix/",
"enabled": true
},
"release": {
"prefix": "release/",
"enabled": false
}
}
}

For a successful request, you will receive the 200 status code and the updated branch configuration.

Example response
{
"development": {
"refId": "refs/heads/master",
"useDefault": false
},
"production": {
"refId": "refs/heads/master",
"useDefault": false
},
"prefixes": {
"bugfix": {
"enabled": true,
"prefix": "bugfix/"
},
"feature": {
"enabled": false,
"prefix": "feature/"
},
"hotfix": {
"enabled": true,
"prefix": "hotfix/"
},
"release": {
"enabled": false,
"prefix": "release/"
}
},
"scope": {
"type": "REPOSITORY"
}
}

Restore default configuration

You can also restore the default branch configuration for your repository. To do that, send the following DELETE request:

curl -X 'DELETE' \
'{baseUrl}/api/v1/tenants/{tenantId}/starsystems/{starSystemId}/repository/{repositoryName}/branch-configuration' \
-H 'Accept: */*' \
-H 'Authorization: Bearer {access_token}'

For a successful request, you will receive the 204 status code.

Legal and support information

Published: December 3, 2024 at 9:55 AM

© 2024 Guidewire Software, Inc.