Skip to content
Ona Docs

CreateSCMIntegration

client.Runners.Configurations.ScmIntegrations.New(ctx, body) (*RunnerConfigurationScmIntegrationNewResponse, error)
POST/gitpod.v1.RunnerConfigurationService/CreateSCMIntegration

Creates a new SCM integration for a runner.

Use this method to:

  • Configure source control access
  • Set up repository integrations
  • Enable code synchronization

Examples

  • Create GitHub integration:

    Sets up GitHub SCM integration.

    runnerId: "d2c94c27-3b76-4a42-b88c-95a85e392c68"
    scmId: "github"
    host: "github.com"
    oauthClientId: "client_id"
    oauthPlaintextClientSecret: "client_secret"
ParametersExpand Collapse
body RunnerConfigurationScmIntegrationNewParams
Host param.Field[string]Optional
IssuerURL param.Field[string]Optional

issuer_url can be set to override the authentication provider URL, if it doesn’t match the SCM host.

OAuthClientID param.Field[string]Optional

oauth_client_id is the OAuth app’s client ID, if OAuth is configured. If configured, oauth_plaintext_client_secret must also be set.

OAuthPlaintextClientSecret param.Field[string]Optional

oauth_plaintext_client_secret is the OAuth app’s client secret in clear text. This will first be encrypted with the runner’s public key before being stored.

Pat param.Field[bool]Optional
RunnerID param.Field[string]Optional
formatuuid
ScmID param.Field[string]Optional

scm_id references the scm_id in the runner’s configuration schema that this integration is for

VirtualDirectory param.Field[string]Optional

virtual_directory is the virtual directory path for Azure DevOps Server (e.g., “/tfs”). This field is only used for Azure DevOps Server SCM integrations and should be empty for other SCM types. Azure DevOps Server APIs work without collection when PAT scope is ‘All accessible organizations’.

ReturnsExpand Collapse
type RunnerConfigurationScmIntegrationNewResponse struct{…}
ID stringOptional

id is a uniquely generated identifier for the SCM integration

formatuuid

CreateSCMIntegration

package main

import (
  "context"
  "fmt"

  "github.com/gitpod-io/gitpod-sdk-go"
  "github.com/gitpod-io/gitpod-sdk-go/option"
)

func main() {
  client := gitpod.NewClient(
    option.WithBearerToken("My Bearer Token"),
  )
  scmIntegration, err := client.Runners.Configurations.ScmIntegrations.New(context.TODO(), gitpod.RunnerConfigurationScmIntegrationNewParams{
    Host: gitpod.F("github.com"),
    OAuthClientID: gitpod.F("client_id"),
    OAuthPlaintextClientSecret: gitpod.F("client_secret"),
    RunnerID: gitpod.F("d2c94c27-3b76-4a42-b88c-95a85e392c68"),
    ScmID: gitpod.F("github"),
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", scmIntegration.ID)
}
{
  "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"
}
Returns Examples
{
  "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"
}