Connecting to a remote repository automatically
By default, all projects that are created on the Automation Decision Services platform are not connected to a remote Git repository (remote repository). However, you can configure the platform to automatically create a remote repository and connect new projects to it.
Before you begin
You need to have the role for administering the Automation Decision Services platform to configure the automatic connection to a remote repository. For more information about the admin role, see Managing user permissions.
- When a user creates a project, it is connected to a remote repository automatically. This is applied for all users.
- When the automatic connection fails, the project is still created but it is not connected to a remote repository.
- When the automatic connection fails, you can still connect to another remote repository manually. For more information, see Connecting to a remote repository manually.
About this task
You can configure to automatically connect to a remote repository by calling a REST API method for Automation Decision Services.
To do so, you must use a valid Zen bearer token.
Procedure
Configuring for the automatic connection
POST ads/rest-api/api/admin/git-providers
{
"name": "my-provider",
"uri": "https://my-server.com",
"type": "GITHUB",
"usePrivateFlag": true,
"apiCredentialsType": "USERNAME_PASSWORD",
"apiCredentials": "my-user:my-password",
"gitCredentialsType": "USERNAME_PASSWORD",
"gitCredentials": "my-user:my-password"
}
Attribute | Mandatory or Optional | Description |
---|---|---|
name |
Mandatory |
A unique name for your Git provider. |
uri |
Mandatory |
The URL for your Git provider API. The current default paths for the supported Git providers:
Tip: You might need to use a different URL and path for specific cases; for example, for
https://github.com , the URL for the provider API is
https://api.github.com .The Certificates must be properly recognized by the Git service pods. |
type |
Mandatory |
The type of your provider. You can choose one of them:
|
apiCredentialsType |
Mandatory |
The type of credentials to access the Git provider API.
You cannot use a clear password for GitHub, and it must be a personal access token instead. |
apiCredentials |
Mandatory |
The value of the credentials. When you use username and password, they must be separated by a colon ( |
gitCredentialsType |
Mandatory |
The type of credentials to access the git repositories. You can use one of them:
|
gitCredentials |
Mandatory |
The value of the credentials. Restriction: You can use only RSA or OpenSSH format.
|
remoteOrg |
Optional |
The organization and namespace to create the repository into. When it's left empty, it uses the default organization of the user that is defined in the
|
usePrivateFlag |
Optional |
It is set to false by default. When it is set to true, the remote repository has private visibility. Note: If you set it to true, the user who is defined in the
gitCredentials
attribute must have access to the remote repository. Use the same user as the one defined in
apiCredentials , or use organization privileges. |
Displaying the automatic connection
GET ads/rest-api/api/admin/git-providers
The credentials are not displayed for security reasons.
Disabling the automatic connection
DELETE ads/rest-api/api/admin/git-providers/my-provider
where
my-provider
is the name of the provider to be deleted.Updating the automatic connection
POST ads/rest-api/api/admin/git-providers/my-provider
where
my-provider
is the name of the provider to be updated.JSON body is the same as the one that is described in Configuring for automatically connecting to a remote repository:
- You must provide all attributes, except that you can omit the credentials. When you don't
provide the credentials, they remain unchanged.Restriction: You cannot update the credentials types:
apiCredentialsType
andgitCredentialsType
. - When you provide the Git credentials, the corresponding secret value is updated. All Git repositories that are previously created with this provider are affected.