Source Control Configuration REST API - v2

NEW IN RELEASE 140

The REST API endpoints described here allow anyone with the  System Administrator role or the Edit System Configuration and Users permission  to manage a Source Control Configuration.

Source Control Configuration Properties

PropertyRequiredDefault ValueValue Used If Not ConfiguredDescription
cloneDirectoryNo"source-control""source-control"The location of cloned repository. If a relative path is given, then it will be created inside the sonatype-work directory.
gitImplementationNonull"native" if available, otherwise "java"The git implementation. Can either be "java" for JGit, or "native" for a native git client.
gitExecutableNonullnullThe absolute path to a native git client. If not provided, then the native git client should be on the system path.
prCommentPurgeWindowNonull180The number of days until PR comment records are allowed to be purged.
prEventPurgeWindowNonull14The number of days until PR event records are allowed to be purged.
gitTimeoutSecondsNo0300The number of seconds a git command can execute before timing out.
commitUsernameNonull"NexusIQ"The commit username for source control management features.
commitEmailNonullnullThe commit email for source control management features. 
useUsernameInRepositoryCloneUrlNofalsefalseIf true, adds the username to the repository clone URL. This is intended to be used in conjunction with commitEmail to support the Bitbucket server "Verified Committer" feature.
defaultBranchMonitoringStartTimeNonullA random time between "00:00" and "00:10"The time at which default branch monitoring will initially execute.
defaultBranchMonitoringIntervalHoursNo2424The period in hours between default branch monitoring executions.
pullRequestMonitoringIntervalSecondsNo6060The period in seconds between pull request monitoring executions.

If no source control configuration is saved, then internally we will use a default configuration when needed, which uses the value for each property if it is not configured.

A source control configuration (default or custom) will only be needed if source control management has been configured for an organization or application.

GET the Source Control Configuration

To get the source control configuration you can make a GET request to the following path:

GET /api/v2/config/sourceControl

Below is an example request to a local IQ Server using the built-in administrator account and the  cURL  tool:

curl -u admin:admin123 http://localhost:8070/api/v2/config/sourceControl

If no source control configuration is saved, then the request yields HTTP status code 404. Otherwise, a JSON response with all the properties described above is returned.

PUT the Source Control Configuration

To set  the source control configuration you can make a PUT request to the following path:

PUT /api/v2/config/sourceControl

The request requires a JSON body as payload.

All properties are optional.

If the source control configuration is being created for the first time, then any property that is not supplied will take its default value.

If the source control configuration already exists, then any supplied properties will have their values updated to the given values.

Below is an example request to a local IQ Server using the built-in administrator account and the  cURL  tool:

curl -u admin:admin123 -X PUT -H "Content-Type: application/json" -d '{"cloneDirectory": "some-clone-directory", "gitImplementation": "native", "prCommentPurgeWindow": 90, "prEventPurgeWindow": 7, "gitExecutable": "/path/to/native/git/executable", "gitTimeoutSeconds": 150, "commitUsername": "some-commit-username", "commitEmail": "some-commit-email@domain", "useUsernameInRepositoryCloneUrl": true, "defaultBranchMonitoringStartTime": "1:11", "defaultBranchMonitoringIntervalHours": 2, "pullRequestMonitoringIntervalSeconds": 3}' http://localhost:8070/api/v2/config/sourceControl

A successful request yields HTTP status code 204.

DELETE the Source Control Configuration

To delete the source control configuration you can make a DELETE request to the following path:

DELETE /api/v2/config/sourceControl

Below is an example request to a local IQ Server using the built-in administrator account and  the cURL  tool:

curl -u admin:admin123 -X DELETE http://localhost:8070/api/v2/config/sourceControl

A successful request yields HTTP status code 204.