brad-jones / teamcity-ts

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

teamcity-ts

TLDR: This is a TypeScript SDK for building TeamCity pipelines, instead of using Kotlin or XML.

import { Project } from "https://deno.land/x/teamcity-ts/mod.ts";

const myPipeline = new Project({ id: "MyPipeline" }, (p) => {
  const host = p.Parameter({ name: "host", value: "1.1.1.1" });

  p.Build({ id: "MyBuild" }, (b) => {
    const count = b.Parameter({ name: "count", value: "3" });

    b.CommandLineRunner({
      id: "MyStep",
      cmd: "ping",
      args: ["-c", `${count}`, `${host}`],
      executionPolicy: "default",
    });
  });
});

HINT: This SDK targets Deno. Node.js support may be possible in the future...

Usage

This SDK is primarily concerned with the generation of the XML & does not provide any further infrastructure to get that XML into the right place at the right time.

Given the above example, it is up to you to do something like this:

const jobs = [];
for (const [filename, doc] of Object.entries(myPipeline.toXml())) {
  jobs.push(Deno.writeTextFile(filename, doc.toString(true)));
}
await Promise.all(jobs);

filename will always begin with .teamcity/ so assuming you tacked the above on to the example & ran it from the root of your repo you would get the expected outcome, that is the following files would be written:

  • ./.teamcity/MyPipeline/project-config.xml
  • ./.teamcity/MyPipeline/buildTypes/MyBuild.xml

For a more complete solution checkout https://github.com/brad-jones/axe

Why not Kotlin?

  • The TeamCity Kotlin DSL documentation has poor coverage.
  • Outside of Java/Android circles, Kotlin as a language is not super well known.
  • The tooling (VsCode Extension / Language Server) for Kotlin is buggy/not very mature.
    • IMO Jetbrains IDEs are bloatware.

Why TypeScript?

  • Through a painstaking process this TypeScript DSL is thoroughly documented & refers to the existing documentation for the TeamCity UI.

  • JavaScript & by extension TypeScript is one of the most ubiquitous languages on the planet. Other projects like the AWS CDK have successfully built similar, arguably much more complex, yet accessible DSLs on top of TypeScript.

  • The tooling for JavaScript/TypeScript is leaps and bounds ahead of the Kotlin developer experience.

read more: ./docs/dsl-design.md

DSL Coverage

I'll be up front right now that I haven't modeled every thing TeamCity provides, only the things that I think are going to matter most but the DSL has escape hatches, similar to the likes of the CDK, so if there is some obscure TeamCity feature that is not modeled, this DSL should still allow you define it in a type safe manner & not stand in your way.

read more: ./docs/extending.md

Legend:

  • βœ”οΈ: This means the feature is fully modeled.
  • πŸ§ͺ: This means the feature also has a test case that proves it works with the latest version of TeamCity.
  • ❌: This means the DSL provides zero support for this feature & you would have to model this yourself with an escape hatch.
Construct Status
Build βœ”οΈ
Build / Dependencies ❌
Build / Extensions / Agent Free Space βœ”οΈ
Build / Extensions / Assembly Info βœ”οΈ
Build / Extensions / Auto Merge βœ”οΈ
Build / Extensions / Commit Status Publishers / Atlassian Stash ❌
Build / Extensions / Commit Status Publishers / Bitbucket Cloud ❌
Build / Extensions / Commit Status Publishers / Gerrit ❌
Build / Extensions / Commit Status Publishers / Github βœ”οΈ
Build / Extensions / Commit Status Publishers / Gitlab ❌
Build / Extensions / Commit Status Publishers / Jetbrains Space ❌
Build / Extensions / Commit Status Publishers / Tfs (AzureDevOps) ❌
Build / Extensions / Commit Status Publishers / Upsource ❌
Build / Extensions / Docker Support βœ”οΈ
Build / Extensions / Failure on Message βœ”οΈ
Build / Extensions / Failure on Metric βœ”οΈ
Build / Extensions / File Content Replacer βœ”οΈ
Build / Extensions / Golang βœ”οΈ
Build / Extensions / Investigations Auto Assigner βœ”οΈ
Build / Extensions / Jira Cloud βœ”οΈ
Build / Extensions / Keep Rules βœ”οΈ
Build / Extensions / Notifiers / Email βœ”οΈ
Build / Extensions / Notifiers / Slack βœ”οΈ
Build / Extensions / Nuget Auth βœ”οΈ
Build / Extensions / Nuget Packages Indexer βœ”οΈ
Build / Extensions / Perfmon βœ”οΈ
Build / Extensions / PR Listeners / Bitbucket Cloud βœ”οΈ
Build / Extensions / PR Listeners / Bitbucket Server βœ”οΈ
Build / Extensions / PR Listeners / Github βœ”οΈ
Build / Extensions / PR Listeners / Gitlab βœ”οΈ
Build / Extensions / PR Listeners / Tfs (AzureDevOps) βœ”οΈ
Build / Extensions / Ruby Env Configurator βœ”οΈ
Build / Extensions / Shared Resources βœ”οΈ
Build / Extensions / SSH Agent βœ”οΈ
Build / Extensions / Swabra βœ”οΈ
Build / Extensions / Vcs Labeling βœ”οΈ
Build / Extensions / Xml Report Plugin βœ”οΈ
Build / Options βœ”οΈ
Build / Requirements βœ”οΈ
Build / Runners / Ant ❌
Build / Runners / Cargo ❌
Build / Runners / Command Line βœ”οΈ
Build / Runners / Conditions βœ”οΈ
Build / Runners / Docker ❌
Build / Runners / Docker Compose ❌
Build / Runners / Dotnet ❌
Build / Runners / Dotnet DupFinder ❌
Build / Runners / Dotnet Inspector ❌
Build / Runners / Duplicator ❌
Build / Runners / FTP ❌
Build / Runners / FxCop ❌
Build / Runners / Gradle ❌
Build / Runners / Inspection ❌
Build / Runners / JPS ❌
Build / Runners / Maven2 ❌
Build / Runners / MSpec ❌
Build / Runners / NAnt ❌
Build / Runners / Nuget Installer ❌
Build / Runners / Nuget Pack ❌
Build / Runners / Nuget Publish ❌
Build / Runners / NUnit ❌
Build / Runners / PowerShell ❌
Build / Runners / Python ❌
Build / Runners / Rake ❌
Build / Runners / SBT ❌
Build / Runners / SMB ❌
Build / Runners / SSH ❌
Build / Triggers / Cron βœ”οΈ
Build / Triggers / Dependency βœ”οΈ
Build / Triggers / Maven Artifact βœ”οΈ
Build / Triggers / Maven Snapshot βœ”οΈ
Build / Triggers / Nuget βœ”οΈ
Build / Triggers / Remote Branch βœ”οΈ
Build / Triggers / Retry βœ”οΈ
Build / Triggers / Vcs βœ”οΈ
Build / Vcs Settings βœ”οΈ
Cleanup βœ”οΈ
Parameter βœ”οΈ
Project βœ”οΈ
Project / Extensions / Issue Trackers / BitBucket βœ”οΈ
Project / Extensions / Issue Trackers / Bugzilla βœ”οΈ
Project / Extensions / Issue Trackers / Github βœ”οΈ
Project / Extensions / Issue Trackers / Jira βœ”οΈ
Project / Extensions / Issue Trackers / Tfs (AzureDevOps) βœ”οΈ
Project / Extensions / Issue Trackers / YouTrack βœ”οΈ
Project / Extensions / Keep Rules βœ”οΈ
Project / Extensions / OAuth Providers / Amazon Docker βœ”οΈ
Project / Extensions / OAuth Providers / BitBucket Cloud βœ”οΈ
Project / Extensions / OAuth Providers / Docker βœ”οΈ
Project / Extensions / OAuth Providers / Github βœ”οΈ
Project / Extensions / OAuth Providers / Gitlab βœ”οΈ
Project / Extensions / OAuth Providers / Jetbrains Space βœ”οΈ
Project / Extensions / OAuth Providers / Slack βœ”οΈ
Project / Extensions / OAuth Providers / Tfs (AzureDevOps) βœ”οΈ
Project / Extensions / Package Repositories / Nuget βœ”οΈ
Project / Extensions / Report Tabs / Build Report βœ”οΈ
Project / Extensions / Report Tabs / Project Report βœ”οΈ
Project / Extensions / Shared Resources βœ”οΈ
Project / Extensions / Versioned Settings βœ”οΈ
VCS Roots / Cvs ❌
VCS Roots / Git βœ”οΈ
VCS Roots / Mercurial ❌
VCS Roots / Perforce ❌
VCS Roots / Star Team ❌
VCS Roots / Svn ❌
VCS Roots / Tfs ❌

Build / Runners

A quick note about the missing build runners, I am of the strong belief that your pipeline should not rely on magic from the builder server. All functionality can be built in your pipeline on top of the Command Line Runner. All of those other types of build runners are magic IMO.

That said if I get PRs for the other build runners, I'm not going to reject them.

About

License:MIT License


Languages

Language:TypeScript 100.0%