TypeScript SDK

Git credentials

Manage project git credentials with @tektona/sdk.

tek.gitCredential manages a project's git credentials. It is project-scoped: the org and project come from the client scope or a per-call { org, project }. Credentials have a project or personal scope; the secret token is write-only and never returned.

List

list returns one Page of credentials:

const page = await tek.gitCredential.list();
const mine = await tek.gitCredential.list({ scope: 'personal' });
for await (const cred of tek.gitCredential.listAll()) console.log(cred.name);

Credential fields: id, name, display_name, forge, scope, owner_user_id, repos (each with repository_id, name, url), created_at, updated_at.

Create

const cred = await tek.gitCredential.create({
  name: 'gh-bot',
  display_name: 'GitHub bot',
  forge: 'github',
  scope: 'project',
  token: process.env.GITHUB_TOKEN!,
  repository_ids: ['<repo-id>'], // or null for none
});

Update

update needs the credential's scope so the API can locate it. It is passed as a trailing option, separate from the request body:

await tek.gitCredential.update(
  cred.id,
  {
    display_name: 'GitHub bot',
    forge: 'github',
    repository_ids: null,
    // token: process.env.GITHUB_TOKEN!, // omit to keep the current token
  },
  { scope: 'project' },
);

Delete

await tek.gitCredential.delete(cred.id, { scope: 'project' }); // idempotent

On this page