Skip to main content

Source Control Configuration REST API

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

Property

Required

Default Value

Value Used If Not Configured

Description

cloneDirectory

No

"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.

gitImplementation

No

null

"native" if available, otherwise "java"

The git implementation. Can either be "java" for JGit, or "native" for a native git client.

gitExecutable

No

null

null

The absolute path to a native git client. If not provided, then the native git client should be on the system path.

prCommentPurgeWindow

No

null

180

The number of days until PR comment records are allowed to be purged.

prEventPurgeWindow

No

null

14

The number of days until PR event records are allowed to be purged.

gitTimeoutSeconds

No

0

300

The number of seconds a git command can execute before timing out.

commitUsername

No

null

"NexusIQ"

The commit username for source control management features.

commitEmail

No

null

null

The commit email for source control management features.

useUsernameInRepositoryCloneUrl

No

false

false

If 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.

defaultBranchMonitoringStartTime

No

null

A random time between "00:00" and "00:10"

The time at which default branch monitoring will initially execute.

defaultBranchMonitoringIntervalHours

No

24

24

The period in hours between default branch monitoring executions.

pullRequestMonitoringIntervalSeconds

No

60

60

The period in seconds between pull request monitoring executions.

Note

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.