### Install Buildkite Go SDK Source: https://github.com/buildkite/buildkite-sdk/blob/main/sdk/go/README.md Use `go get` to install the SDK package. ```bash go get github.com/buildkite/buildkite-sdk/sdk/go ``` -------------------------------- ### Install Buildkite SDK Source: https://github.com/buildkite/buildkite-sdk/blob/main/sdk/python/README.md Install the buildkite-sdk package using uv. ```bash uv add buildkite-sdk ``` -------------------------------- ### Define Multiple Dependencies Source: https://github.com/buildkite/buildkite-sdk/blob/main/sdk/csharp/README.md Configure a step to run only after multiple specified steps have successfully completed. This example requires both 'build' and 'test' to finish before 'deploy' starts. ```csharp // Multiple dependencies pipeline.AddStep(new CommandStep { Label = ":rocket: Deploy", Command = "deploy.sh", DependsOn = new string[] { "build", "test" } }); ``` -------------------------------- ### Quick Start: Create a Buildkite Pipeline in C# Source: https://github.com/buildkite/buildkite-sdk/blob/main/sdk/csharp/README.md Initialize a pipeline and add command and wait steps. Output the pipeline configuration as YAML. ```csharp using Buildkite.Sdk; using Buildkite.Sdk.Schema; var pipeline = new Pipeline(); pipeline.AddStep(new CommandStep { Label = ":hammer: Build", Command = "dotnet build" }); pipeline.AddStep(new WaitStep()); pipeline.AddStep(new CommandStep { Label = ":test_tube: Test", Command = "dotnet test" }); // Output as YAML for `buildkite-agent pipeline upload` Console.WriteLine(pipeline.ToYaml()); ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/buildkite/buildkite-sdk/blob/main/README.md Run this command to install all project dependencies using npm. ```bash npm install ``` -------------------------------- ### Install Buildkite SDK Source: https://github.com/buildkite/buildkite-sdk/blob/main/sdk/typescript/README.md Install the Buildkite SDK package using npm. ```bash npm install @buildkite/buildkite-sdk ``` -------------------------------- ### Install Buildkite SDK for .NET Source: https://github.com/buildkite/buildkite-sdk/blob/main/sdk/csharp/index.md Add the Buildkite.Sdk package to your .NET project using the dotnet CLI. ```bash dotnet add package Buildkite.Sdk ``` -------------------------------- ### Install Buildkite SDK Source: https://github.com/buildkite/buildkite-sdk/blob/main/sdk/ruby/README.md Install the Buildkite SDK gem using the standard Ruby package manager. ```bash gem install buildkite-sdk ``` -------------------------------- ### Install Dependencies with Homebrew and Mise Source: https://github.com/buildkite/buildkite-sdk/blob/main/README.md Use this command to install all necessary development tools and dependencies if you are on a Mac and use Homebrew and Mise. ```bash brew bundle mise install ``` -------------------------------- ### Configure Agents Using Object Format Source: https://github.com/buildkite/buildkite-sdk/blob/main/sdk/csharp/README.md Assign a step to specific Buildkite agents using key-value pairs. This example targets agents with the 'linux' queue and 'dotnet' tag. ```csharp // Object format (key-value pairs) pipeline.AddStep(new CommandStep { Label = ":dotnet: Build", Command = "dotnet build", Agents = new AgentsObject { ["queue"] = "linux", ["dotnet"] = "true" } }); ``` -------------------------------- ### Specify Artifact Paths for Upload Source: https://github.com/buildkite/buildkite-sdk/blob/main/sdk/csharp/README.md Define which files or directories should be uploaded as build artifacts after a step completes. This example uploads published output and log files. ```csharp pipeline.AddStep(new CommandStep { Label = ":package: Package", Command = "dotnet publish -o ./out", ArtifactPaths = new[] { "out/**/*", "logs/*.txt" } }); ``` -------------------------------- ### Upgrade Nx Workspace Source: https://github.com/buildkite/buildkite-sdk/blob/main/README.md Migrates the Nx workspace to the latest version. Refer to the nx guide for detailed instructions. ```bash npx nx migrate latest ``` -------------------------------- ### Configure Cache for Build Artifacts Source: https://github.com/buildkite/buildkite-sdk/blob/main/sdk/csharp/README.md Implement caching for build artifacts, such as NuGet packages, to speed up subsequent builds. This example caches the NuGet packages directory. ```csharp pipeline.AddStep(new CommandStep { Label = ":dotnet: Build", Command = "dotnet build", Cache = new Cache { Name = "nuget-packages", Paths = new List { "~/.nuget/packages" }, Size = "5g" } }); ``` -------------------------------- ### Define Single Dependency Source: https://github.com/buildkite/buildkite-sdk/blob/main/sdk/csharp/README.md Specify a single preceding step that must complete before the current step can run. This example sets 'build' as a dependency for the 'test' step. ```csharp // Single dependency pipeline.AddStep(new CommandStep { Label = ":test_tube: Test", Command = "dotnet test", DependsOn = "build" }); ``` -------------------------------- ### Conditional Step with Boolean Expression Source: https://github.com/buildkite/buildkite-sdk/blob/main/sdk/csharp/README.md Execute a step only when a specific condition is met, defined by a boolean expression. This example deploys only when the build is on the 'main' branch. ```csharp // Conditional step using a boolean expression pipeline.AddStep(new CommandStep { Label = ":rocket: Deploy", Command = "deploy.sh", If = "build.branch == 'main'" }); ``` -------------------------------- ### Update Fields to Struct in BlockStep Source: https://github.com/buildkite/buildkite-sdk/blob/main/docs/v0.0.4-breaking-changes.md The `Fields` field in `BlockStep` is now a struct. This example shows how to define both Text and Select fields with their respective properties. ```go step := buildkite.BlockStep{ Fields: []buildkite.FieldsItem{ // Text Field { TextField: &buildkite.TextField{ Default: buildkite.Value("default"), Format: buildkite.Value("format"), Hint: buildkite.Value("hint"), Key: buildkite.Value("key"), Required: &buildkite.TextFieldRequired{ String: buildkite.Value("true"), }, Text: buildkite.Value("text"), }, }, // Select Field { SelectField: &buildkite.SelectField{ Default: &buildkite.SelectFieldDefault{ String: buildkite.Value("default"), }, Hint: buildkite.Value("hint"), Key: buildkite.Value("key"), Select: buildkite.Value("select"), Multiple: &buildkite.SelectFieldMultiple{ Bool: buildkite.Value(true), }, Required: &buildkite.SelectFieldRequired{ Bool: buildkite.Value(true), }, Options: []buildkite.SelectFieldOption{ {Value: buildkite.Value("optionValue")}, }, } }, }, } ``` -------------------------------- ### Use Secrets by Name Source: https://github.com/buildkite/buildkite-sdk/blob/main/sdk/csharp/README.md Access secrets defined in Buildkite by their names, making them available as environment variables within the step. This example uses 'npm-token' and 'deploy-key'. ```csharp // List of secret names pipeline.AddStep(new CommandStep { Label = ":closed_lock_with_key: Deploy", Command = "deploy.sh", Secrets = new[] { "npm-token", "deploy-key" } }); ``` -------------------------------- ### Configure Step-Level Notifications Source: https://github.com/buildkite/buildkite-sdk/blob/main/sdk/csharp/README.md Assign notifications, like Slack messages, to individual steps within a pipeline. This example shows a deployment step with a Slack notification. ```csharp // Step-level notifications pipeline.AddStep(new CommandStep { Label = ":rocket: Deploy", Command = "deploy.sh", Notify = new List { new SlackNotification { Slack = "#deploys" } } }); ``` -------------------------------- ### Add a Group Step to a Buildkite Pipeline Source: https://github.com/buildkite/buildkite-sdk/blob/main/sdk/csharp/README.md Organize multiple steps under a single group with a label. This example groups two command steps for unit and integration tests. ```csharp pipeline.AddStep(new GroupStep { Group = ":test_tube: Tests", Steps = new List { new CommandStep { Label = "Unit", Command = "dotnet test" }, new CommandStep { Label = "Integration", Command = "dotnet test --filter Integration" } } }); ``` -------------------------------- ### Configure Concurrency Settings Source: https://github.com/buildkite/buildkite-sdk/blob/main/sdk/csharp/README.md Control how many builds can run concurrently for a specific group. This example sets a concurrency limit of 1 for the 'deploy/production' group using an eager method. ```csharp pipeline.AddStep(new CommandStep { Label = ":rocket: Deploy", Command = "deploy.sh", Concurrency = 1, ConcurrencyGroup = "deploy/production", ConcurrencyMethod = "eager" }); ``` -------------------------------- ### Update Branches to Struct in InputStep Source: https://github.com/buildkite/buildkite-sdk/blob/main/docs/v0.0.4-breaking-changes.md The `Branches` field in `InputStep` is no longer a `[]string` and is now a struct named `Branches`. This example shows how to set a single branch or an array of branches. ```go step := buildkite.InputStep{ Branches: &buildkite.Branches{ String: buildkite.Value("one"), } } ``` ```go listValues := []string{"one","two"} step := buildkite.InputStep{ Branches: &buildkite.Branches{ StringArray: listValues, } } ``` -------------------------------- ### Update Fields to Struct in InputStep Source: https://github.com/buildkite/buildkite-sdk/blob/main/docs/v0.0.4-breaking-changes.md The `Fields` field in `InputStep` is no longer an interface and is now defined as a struct. This example demonstrates configuring both a `TextField` and a `SelectField` with various options. ```go step := buildkite.InputStep{ Fields: []buildkite.FieldsItem{ // Text Field { TextField: &buildkite.TextField{ Default: buildkite.Value("default"), Format: buildkite.Value("format"), Hint: buildkite.Value("hint"), Key: buildkite.Value("key"), Required: &buildkite.TextFieldRequired{ String: buildkite.Value("true"), }, Text: buildkite.Value("text"), }, }, // Select Field { SelectField: &buildkite.SelectField{ Default: &buildkite.SelectFieldDefault{ String: buildkite.Value("default"), }, Hint: buildkite.Value("hint"), Key: buildkite.Value("key"), Select: buildkite.Value("select"), Multiple: &buildkite.SelectFieldMultiple{ Bool: buildkite.Value(true), }, Required: &buildkite.SelectFieldRequired{ Bool: buildkite.Value(true), }, Options: []buildkite.SelectFieldOption{ {Value: buildkite.Value("optionValue")}, }, } }, }, } ``` -------------------------------- ### Conditional Step with File Changes Source: https://github.com/buildkite/buildkite-sdk/blob/main/sdk/csharp/README.md Run a step only if specific files or patterns have changed since the last build. This example rebuilds the project if source files orcsproj files are modified. ```csharp // Run only when specific files change pipeline.AddStep(new CommandStep { Label = ":dotnet: Build", Command = "dotnet build", IfChanged = new[] { "src/**", "*.csproj" } }); ``` -------------------------------- ### Update Steps to Slice of Structs in GroupStep Source: https://github.com/buildkite/buildkite-sdk/blob/main/docs/v0.0.4-breaking-changes.md The `Steps` field in `GroupStep` is no longer a slice of interfaces and now is a slice of structs. This example shows how to define a `CommandStep` within the `Steps` slice. ```go steps := buildkite.GroupStep{ Steps: &buildkite.GroupSteps{ { CommandStep: &buildkite.CommandStep{ Command: &buildkite.CommandStepCommand{ String: buildkite.Value("command.sh"), }, }, }, }, } ``` -------------------------------- ### Update Notify to BuildNotify in GroupStep Source: https://github.com/buildkite/buildkite-sdk/blob/main/docs/v0.0.4-breaking-changes.md The `Notify` field in `GroupStep` is no longer an interface and is now `BuildNotify`. Update notify blocks to use the new type, for example, to notify a Slack channel. ```go step := buildkite.GroupStep{ Notify: &buildkite.BuildNotify{ { NotifySlack: &buildkite.NotifySlack{ Slack: &buildkite.NotifySlackSlack{ String: buildkite.Value("#channel"), }, }, }, }, } ``` -------------------------------- ### Serve SDK Documentation Locally Source: https://github.com/buildkite/buildkite-sdk/blob/main/README.md Serves the SDK documentation locally. This command also implicitly builds the documentation. ```bash npm run docs:serve ``` -------------------------------- ### Build SDK Documentation Source: https://github.com/buildkite/buildkite-sdk/blob/main/README.md Builds all SDK documentation and writes it to the ./dist/docs directory. ```bash npm run docs ``` -------------------------------- ### Basic Pipeline Creation with Buildkite SDK Source: https://github.com/buildkite/buildkite-sdk/blob/main/sdk/typescript/README.md Demonstrates how to create a new pipeline and add a simple command step using the Buildkite SDK. Outputs the pipeline configuration in JSON and YAML formats. ```javascript const { Pipeline } = require("@buildkite/buildkite-sdk"); const pipeline = new Pipeline(); pipeline.addStep({ command: "echo 'Hello, world!'", }); console.log(pipeline.toJSON()); console.log(pipeline.toYAML()); ``` -------------------------------- ### Build All SDKs Source: https://github.com/buildkite/buildkite-sdk/blob/main/README.md This command builds all the SDKs and outputs them to the ./dist/sdks directory. ```bash npm run build ``` -------------------------------- ### Create and Serialize a Buildkite Pipeline in Go Source: https://github.com/buildkite/buildkite-sdk/blob/main/sdk/go/README.md Demonstrates how to add a command step to a pipeline and serialize it to JSON and YAML. Ensure you have the necessary imports. ```go package main import ( "fmt" "github.com/buildkite/buildkite-sdk/sdk/go/sdk/buildkite" "log" ) func main() { pipeline := buildkite.Pipeline{} pipeline.AddStep(buildkite.CommandStep{ Command: &buildkite.CommandStepCommand{ String: buildkite.Value("echo 'Hello, world!"), }, }) json, err := pipeline.ToJSON() if err != nil { log.Fatalf("Failed to serialize JSON: %v", err) } fmt.Println(json) yaml, err := pipeline.ToYAML() if err != nil { log.Fatalf("Failed to serialize YAML: %v", err) } fmt.Println(yaml) } ``` -------------------------------- ### Build Project Source: https://github.com/buildkite/buildkite-sdk/blob/main/sdk/csharp/README.md Standard command to build a .NET project using the dotnet CLI. ```bash dotnet build ``` -------------------------------- ### Test All SDKs and Apps Source: https://github.com/buildkite/buildkite-sdk/blob/main/README.md Execute this command to run all tests for the SDKs and applications within the project. ```bash npm test ``` -------------------------------- ### Develop with Live Reload Source: https://github.com/buildkite/buildkite-sdk/blob/main/README.md Launches web servers for all docsets and watches all projects for changes, requiring a reload for updates. ```bash npm run dev ``` -------------------------------- ### Create and Print Pipeline Source: https://github.com/buildkite/buildkite-sdk/blob/main/sdk/python/README.md Instantiate the Pipeline class, add a command step, and print the pipeline configuration in JSON and YAML formats. ```python from buildkite_sdk import Pipeline pipeline = Pipeline() pipeline.add_step({"command": "echo 'Hello, world!'"}) print(pipeline.to_json()) print(pipeline.to_yaml()) ``` -------------------------------- ### Publish Documentation to AWS Source: https://github.com/buildkite/buildkite-sdk/blob/main/README.md Uploads the generated documentation to AWS. ```bash npm run docs:publish ``` -------------------------------- ### Test Project Source: https://github.com/buildkite/buildkite-sdk/blob/main/sdk/csharp/README.md Standard command to run tests for a .NET project using the dotnet CLI. ```bash dotnet test ``` -------------------------------- ### Define Simple Matrix Build Source: https://github.com/buildkite/buildkite-sdk/blob/main/sdk/csharp/README.md Configure a command step to run with different runtime and OS combinations using a matrix. The label dynamically includes matrix variables. ```csharp // Simple matrix pipeline.AddStep(new CommandStep { Label = "Test {{matrix.runtime}}", Command = "dotnet test", Matrix = new Matrix { Setup = new Dictionary> { ["runtime"] = new List { "net8.0", "net9.0" }, ["os"] = new List { "linux", "windows" } } } }); ``` -------------------------------- ### Add Plugins to a Buildkite Command Step Source: https://github.com/buildkite/buildkite-sdk/blob/main/sdk/csharp/README.md Configure plugins for a command step, including simple plugin references and plugins with specific configurations. ```csharp // Simple plugin (no configuration) pipeline.AddStep(new CommandStep { Label = ":docker: Build", Command = "build.sh", Plugins = new object[] { "docker-login#v3.0.0" } }); // Plugin with configuration pipeline.AddStep(new CommandStep { Label = ":docker: Run", Command = "dotnet test", Plugins = new object[] { new Dictionary { ["docker#v5.11.0"] = new { image = "mcr.microsoft.com/dotnet/sdk:9.0" } } } }); // Mixing simple and configured plugins pipeline.AddStep(new CommandStep { Label = ":rocket: Deploy", Command = "deploy.sh", Plugins = new object[] { "docker-login#v3.0.0", new Dictionary { ["ecr#v2.9.0"] = new { login = true, account_ids = "123456789" } } } }); ``` -------------------------------- ### Run All Apps Source: https://github.com/buildkite/buildkite-sdk/blob/main/README.md Executes all applications, writing JSON and YAML pipelines to the ./out directory. ```bash npm run apps ``` -------------------------------- ### Configure Agents Using List Format Source: https://github.com/buildkite/buildkite-sdk/blob/main/sdk/csharp/README.md Specify agent requirements as a list of 'key=value' strings. This achieves the same result as the object format for targeting specific agents. ```csharp // List format (key=value strings) pipeline.AddStep(new CommandStep { Label = ":dotnet: Build", Command = "dotnet build", Agents = new AgentsList { "queue=linux", "dotnet=true" } }); ``` -------------------------------- ### Define Matrix Build with Adjustments Source: https://github.com/buildkite/buildkite-sdk/blob/main/sdk/csharp/README.md Set up a matrix build that includes specific adjustments, such as soft-failing a particular combination of runtime and OS. ```csharp // Matrix with adjustments pipeline.AddStep(new CommandStep { Label = "Test {{matrix.runtime}} on {{matrix.os}}", Command = "dotnet test", Matrix = new Matrix { Setup = new Dictionary> { ["runtime"] = new List { "net8.0", "net9.0" }, ["os"] = new List { "linux", "windows" } }, Adjustments = new List { new MatrixAdjustment { With = new Dictionary { ["runtime"] = "net8.0", ["os"] = "windows" }, SoftFail = true } } } }); ``` -------------------------------- ### Create and Push Release Tags Source: https://github.com/buildkite/buildkite-sdk/blob/main/README.md After merging the release PR, create and push the main and SDK-specific release tags from an up-to-date main branch. ```bash git tag v{VERSION_TO} main git tag sdk/go/v{VERSION_TO} main git push origin v{VERSION_TO} git push origin sdk/go/v{VERSION_TO} ``` -------------------------------- ### Pack Project Source: https://github.com/buildkite/buildkite-sdk/blob/main/sdk/csharp/README.md Command to pack a .NET project into a NuGet package in Release configuration. ```bash dotnet pack -c Release ``` -------------------------------- ### Add a Command Step to a Buildkite Pipeline Source: https://github.com/buildkite/buildkite-sdk/blob/main/sdk/csharp/README.md Configure a command step with a label, key, command, agent queue, and timeout. ```csharp pipeline.AddStep(new CommandStep { Label = ":dotnet: Build", Key = "build", Command = "dotnet build --configuration Release", Agents = new AgentsObject { ["queue"] = "linux" }, TimeoutInMinutes = 30 }); ``` -------------------------------- ### Define Pipeline Steps with Buildkite SDK for .NET Source: https://github.com/buildkite/buildkite-sdk/blob/main/sdk/csharp/index.md Use the Buildkite SDK to programmatically define pipeline steps, such as commands for testing and building. The pipeline can then be output as YAML or JSON. ```csharp using Buildkite.Sdk; using Buildkite.Sdk.Schema; var pipeline = new Pipeline(); pipeline.AddStep(new CommandStep { Label = "Test", Command = "dotnet test" }); pipeline.AddStep(new CommandStep { Label = "Build", Command = "dotnet build --configuration Release" }); // Output as YAML Console.WriteLine(pipeline.ToYaml()); // Output as JSON Console.WriteLine(pipeline.ToJson()); ``` -------------------------------- ### Publish to Package Registries Source: https://github.com/buildkite/buildkite-sdk/blob/main/README.md Publishes the SDKs to npm, PyPi pkg.go.dev, and RubyGems. ```bash npm run publish ``` -------------------------------- ### Create a Buildkite Pipeline in Ruby Source: https://github.com/buildkite/buildkite-sdk/blob/main/sdk/ruby/README.md Use the Buildkite SDK to programmatically define and generate pipeline configurations in JSON or YAML format. Requires the 'buildkite' gem. ```ruby require "buildkite" pipeline = Buildkite::Pipeline.new pipeline.add_step( label: "some-label", command: "echo 'Hello, World!'" ) puts pipeline.to_json puts pipeline.to_yaml ``` -------------------------------- ### Format SDK Code Source: https://github.com/buildkite/buildkite-sdk/blob/main/README.md Formats all SDK code according to project standards. ```bash npm run format ``` -------------------------------- ### Configure Retry Options for a Buildkite Step Source: https://github.com/buildkite/buildkite-sdk/blob/main/sdk/csharp/README.md Set up automatic retries based on exit status and limit, or enable manual retries with a reason. ```csharp pipeline.AddStep(new CommandStep { Label = ":test_tube: Tests", Command = "dotnet test", Retry = new Retry { Automatic = new AutomaticRetry { ExitStatus = "*", Limit = 2 }, Manual = new ManualRetry { PermitOnPassed = true, Reason = "Re-run if flaky" } } }); ``` -------------------------------- ### Create Release Branch for SDKs Source: https://github.com/buildkite/buildkite-sdk/blob/main/README.md Run this command to create a new branch for releasing SDKs. It updates version numbers, rebuilds SDKs, commits changes, and pushes the branch to GitHub. ```bash npm run release:create-branch ``` -------------------------------- ### Add an Input Step to a Buildkite Pipeline Source: https://github.com/buildkite/buildkite-sdk/blob/main/sdk/csharp/README.md Define an input step with text and select fields for user interaction. Fields can be marked as required and have default values. ```csharp pipeline.AddStep(new InputStep { Input = ":writing_hand: Release Details", Key = "release-info", Prompt = "Provide release information", Fields = new List { new TextField { Key = "release-notes", Text = "Release Notes", Hint = "Markdown supported", Required = true }, new SelectField { Key = "environment", Select = "Target Environment", Options = new List { new SelectOption { Label = "Staging", Value = "staging" }, new SelectOption { Label = "Production", Value = "production" } }, Default = "staging" } } }); ``` -------------------------------- ### Configure Pipeline-Level Notifications Source: https://github.com/buildkite/buildkite-sdk/blob/main/sdk/csharp/README.md Add pipeline-level notifications for Slack or email that trigger based on build status, such as when a build fails. ```csharp // Pipeline-level notifications pipeline.AddNotify(new SlackNotification { Slack = new SlackConfig { Channels = new List { "#builds" }, Message = "Build finished" }, If = "build.state == 'failed'" }); pipeline.AddNotify(new EmailNotification { Email = "team@example.com", If = "build.state == 'failed'" }); ``` -------------------------------- ### Allow Dependency Failure Source: https://github.com/buildkite/buildkite-sdk/blob/main/sdk/csharp/README.md Configure a step to proceed even if a specified dependency fails. This is useful for reporting or cleanup tasks that should run regardless of prior step success. ```csharp // Allow a dependency to fail pipeline.AddStep(new CommandStep { Label = ":page_facing_up: Report", Command = "generate-report.sh", DependsOn = DependsOn.FromDependencies( new Dependency { Step = "test", AllowFailure = true } ) }); ``` -------------------------------- ### Configure Soft Fail and Skip for Buildkite Steps Source: https://github.com/buildkite/buildkite-sdk/blob/main/sdk/csharp/README.md Mark steps as soft fail to allow the pipeline to continue on certain exit statuses, or skip a step with a reason. ```csharp // Soft fail on any exit status pipeline.AddStep(new CommandStep { Label = ":lint: Optional Lint", Command = "dotnet format --verify-no-changes", SoftFail = true }); // Soft fail on specific exit statuses pipeline.AddStep(new CommandStep { Label = ":warning: Flaky Test", Command = "dotnet test --filter Flaky", SoftFail = SoftFail.FromConditions( new SoftFailCondition { ExitStatus = 1 }, new SoftFailCondition { ExitStatus = SoftFailExitStatus.FromWildcard() } ) }); // Skip with a reason pipeline.AddStep(new CommandStep { Label = ":no_entry: Disabled", Command = "echo skipped", Skip = "Temporarily disabled pending fix" }); ``` -------------------------------- ### Watch Projects for Changes Source: https://github.com/buildkite/buildkite-sdk/blob/main/README.md Monitors all projects for changes, automatically rebuilding docs and SDKs, and re-running apps. ```bash npm run watch ``` -------------------------------- ### Add Wait Steps to a Buildkite Pipeline Source: https://github.com/buildkite/buildkite-sdk/blob/main/sdk/csharp/README.md Include wait steps to pause pipeline execution. A wait step can be configured to continue on failure. ```csharp pipeline.AddStep(new WaitStep()); pipeline.AddStep(new WaitStep { ContinueOnFailure = true }); ``` -------------------------------- ### Map Secrets to Environment Variables Source: https://github.com/buildkite/buildkite-sdk/blob/main/sdk/csharp/README.md Map specific Buildkite secrets to custom environment variable names within a step. This allows for more granular control over secret exposure. ```csharp // Map environment variables to secrets pipeline.AddStep(new CommandStep { Label = ":closed_lock_with_key: Publish", Command = "publish.sh", Secrets = new Dictionary { ["NPM_TOKEN"] = "org/npm-token", ["DEPLOY_KEY"] = "org/deploy-key" } }); ``` -------------------------------- ### Add a Block Step to a Buildkite Pipeline Source: https://github.com/buildkite/buildkite-sdk/blob/main/sdk/csharp/README.md Add a block step that requires manual confirmation before proceeding. ```csharp pipeline.AddStep(new BlockStep { Block = ":rocket: Deploy to Production?", Prompt = "Are you sure?" }); ``` -------------------------------- ### Regenerate Types for All Languages Source: https://github.com/buildkite/buildkite-sdk/blob/main/README.md Runs the type generator to fetch the latest schema and regenerate types for all supported languages. ```bash npm run types ``` -------------------------------- ### Convert Pipeline to YAML Source: https://github.com/buildkite/buildkite-sdk/blob/main/sdk/csharp/README.md Generate the YAML representation of the pipeline configuration, which is typically used for uploading to the Buildkite agent. ```csharp string yaml = pipeline.ToYaml(); // For buildkite-agent pipeline upload ``` -------------------------------- ### Add a Trigger Step to a Buildkite Pipeline Source: https://github.com/buildkite/buildkite-sdk/blob/main/sdk/csharp/README.md Add a trigger step to initiate another pipeline, specifying the branch to build. ```csharp pipeline.AddStep(new TriggerStep { Trigger = "deploy-pipeline", Build = new TriggerBuild { Branch = "main" } }); ``` -------------------------------- ### Clean Build and Test Artifacts Source: https://github.com/buildkite/buildkite-sdk/blob/main/README.md Removes build and test artifacts from the project. ```bash npm run clean ``` -------------------------------- ### Update CancelOnBuildFailing to struct in Command Step Source: https://github.com/buildkite/buildkite-sdk/blob/main/docs/v0.0.4-breaking-changes.md The CancelOnBuildFailing field is no longer a bool and is now a struct. Use the Bool or String field within the struct to set the value. ```go // Bool step := buildkite.CommandStep{ CancelOnBuildFailing: &buildkite.CancelOnBuildFailing{ Bool: buildkite.Value(true), } } ``` ```go // String step := buildkite.CommandStep{ CancelOnBuildFailing: &buildkite.CancelOnBuildFailing{ String: buildkite.Value("true"), } } ``` -------------------------------- ### Update AllowDependencyFailure to Struct in InputStep Source: https://github.com/buildkite/buildkite-sdk/blob/main/docs/v0.0.4-breaking-changes.md The `AllowDependencyFailure` field in `InputStep` is no longer a bool and now requires a struct. Use `buildkite.Value(true)` for boolean true or `buildkite.Value("true")` for string true. ```go // Boolean step := buildkite.InputStep{ AllowDependencyFailure: &buildkite.AllowDependencyFailure{ Bool: buildkite.Value(true), } } ``` ```go // String step := buildkite.InputStep{ AllowDependencyFailure: &buildkite.AllowDependencyFailure{ String: buildkite.Value("true"), } } ``` -------------------------------- ### Update Skip to Struct in GroupStep Source: https://github.com/buildkite/buildkite-sdk/blob/main/docs/v0.0.4-breaking-changes.md The `Skip` field in `GroupStep` is no longer a bool and now requires a struct. Use `buildkite.Value(true)` for boolean true or `buildkite.Value("true")` for string true. ```go // Bool step := buildkite.GroupStep{ Skip: &buildkite.Skip{ Bool: buildkite.Value(true), } } ``` ```go // String step := buildkite.GroupStep{ Skip: &buildkite.Skip{ String: buildkite.Value("true"), } } ``` -------------------------------- ### Access Environment Variables Source: https://github.com/buildkite/buildkite-sdk/blob/main/sdk/csharp/README.md Retrieve common Buildkite environment variables like branch, commit, and build number using the SDK's `EnvironmentVariable` class. ```csharp using Buildkite.Sdk; var branch = EnvironmentVariable.Branch; var commit = EnvironmentVariable.Commit; var buildNumber = EnvironmentVariable.BuildNumber; ``` -------------------------------- ### Update DependsOn to Struct in InputStep Source: https://github.com/buildkite/buildkite-sdk/blob/main/docs/v0.0.4-breaking-changes.md The `DependsOn` field in `InputStep` is no longer an interface and now requires a struct. Provide a single step name as a string or a list of dependencies. ```go singleValue := "step" step := buildkite.InputStep{ DependsOn: &buildkite.DependsOn{ String: buildkite.Value("step"), } } ``` ```go step := buildkite.InputStep{ DependsOn: []buildkite.DependsOnListItem{ {String: buildkite.Value("one")}, { DependsOnList: &buildkite.DependsOnListObject{ Step: buildkite.Value("two"), }, } } } ``` -------------------------------- ### Access Buildkite Environment Variables with .NET SDK Source: https://github.com/buildkite/buildkite-sdk/blob/main/sdk/csharp/index.md Access Buildkite environment variables with type safety using the Buildkite SDK. This includes retrieving the build number, branch name, and checking if the code is running in a CI environment. ```csharp using Buildkite.Sdk; // Get the current build number var buildNumber = Environment.BuildNumber; // Get the branch name var branch = Environment.Branch; // Check if running in CI var isCI = Environment.CI; ``` -------------------------------- ### Update Signature Type to CommandStepSignature Source: https://github.com/buildkite/buildkite-sdk/blob/main/docs/v0.0.4-breaking-changes.md The `Signature` type has been renamed to `CommandStepSignature`. Use this new type for defining step signatures. ```go step := buildkite.CommandStep{ Signature: &buildkite.CommandStepSignature{ Algorithm: buildkite.Value("algo"), SignedFields: []string{"one","two"}, Value: buildkite.Value("value"), }, } ``` -------------------------------- ### Update AllowDependencyFailure to Struct in GroupStep Source: https://github.com/buildkite/buildkite-sdk/blob/main/docs/v0.0.4-breaking-changes.md The `AllowDependencyFailure` field in `GroupStep` is no longer a bool and now requires a struct. Use `buildkite.Value(true)` for boolean true or `buildkite.Value("true")` for string true. ```go // Boolean step := buildkite.GroupStep{ AllowDependencyFailure: &buildkite.AllowDependencyFailure{ Bool: buildkite.Value(true), } } ``` ```go // String step := buildkite.GroupStep{ AllowDependencyFailure: &buildkite.AllowDependencyFailure{ String: buildkite.Value("true"), } } ``` -------------------------------- ### Convert Pipeline to JSON Source: https://github.com/buildkite/buildkite-sdk/blob/main/sdk/csharp/README.md Generate the JSON representation of the pipeline configuration. This format can be useful for API interactions or other programmatic uses. ```csharp string json = pipeline.ToJson(); // JSON format ``` -------------------------------- ### Update Plugins Type to Struct Source: https://github.com/buildkite/buildkite-sdk/blob/main/docs/v0.0.4-breaking-changes.md The `Plugins` field is now a struct instead of a map. This change affects how plugins are defined and accessed. ```go step := buildkite.CommandStep{ Plugins: &buildkite.Plugins{ PluginsList: &buildkite.PluginsList{ { PluginsList: &buildkite.PluginsListObject{ "docker": map[string]interface{}{ "foo": "bar", }, }, }, }, }, } ``` -------------------------------- ### Update Notify Type to CommandStepNotify Source: https://github.com/buildkite/buildkite-sdk/blob/main/docs/v0.0.4-breaking-changes.md The `Notify` interface has been renamed to `CommandStepNotify`. Update all notify blocks to use the new type. ```go step := buildkite.CommandStep{ Notify: &buildkite.CommandStepNotify{ { NotifySlack: &buildkite.NotifySlack{ Slack: &buildkite.NotifySlackSlack{ String: buildkite.Value("#channel"), }, }, }, }, } ``` -------------------------------- ### Regenerate Types for Specific Languages Source: https://github.com/buildkite/buildkite-sdk/blob/main/README.md Commands to regenerate types specifically for TypeScript, Python, or Go. ```bash npm run types-ts ``` ```bash npm run types-py ``` ```bash npm run types-go ``` -------------------------------- ### Update Matrix to struct in Command Step Source: https://github.com/buildkite/buildkite-sdk/blob/main/docs/v0.0.4-breaking-changes.md The Matrix field is no longer an interface and is now a struct named Matrix. Use MatrixElementList or MatrixObject fields within the struct. ```go // List step := buildkite.CommandStep{ Matrix: &buildkite.Matrix{ MatrixElementList: buildkite.Value(buildkite.MatrixElementList{ { String: buildkite.Value("value"), }, { Bool: buildkite.Value(true), }, { Int: buildkite.Value(1), }, }), }, } ``` ```go // Object step := buildkite.CommandStep{ Matrix: &buildkite.Matrix{ MatrixObject: &buildkite.MatrixObject{ Setup: &buildkite.MatrixSetup{ MatrixSetup: buildkite.Value(map[string][]buildkite.MatrixElement{ "foo": { { String: buildkite.Value("bar"), }, { Bool: buildkite.Value(true), }, { Int: buildkite.Value(1), }, }, }), }, }, }, } ``` -------------------------------- ### Update SoftFail to Struct in TriggerStep Source: https://github.com/buildkite/buildkite-sdk/blob/main/docs/v0.0.4-breaking-changes.md The `SoftFail` field in `TriggerStep` is now a struct. It can be configured as a simple boolean or a list of exit statuses. ```go // Simple step := buildkite.TriggerStep{ SoftFail: &buildkite.SoftFail{ SoftFailEnum: &buildkite.SoftFailEnum{ Bool: buildkite.Value(true), }, }, } ``` ```go // List step := buildkite.TriggerStep{ SoftFail: &buildkite.SoftFail{ SoftFailList: []buildkite.SoftFailObject{ { ExitStatus: &buildkite.SoftFailObjectExitStatus{ Int: buildkite.Value(1), }, }, }, }, } ``` -------------------------------- ### Update Async to Struct in TriggerStep Source: https://github.com/buildkite/buildkite-sdk/blob/main/docs/v0.0.4-breaking-changes.md The `Async` field in `TriggerStep` is now a struct named `TriggerStepAsync`. Set its value using either the `Bool` or `String` field. ```go // Boolean step := buildkite.TriggerStep{ Async: &buildkite.TriggerStepAsync{ Bool: buildkite.Value(true), } } ``` ```go // String step := buildkite.TriggerStep{ Async: &buildkite.TriggerStepAsync{ String: buildkite.Value("true"), } } ``` -------------------------------- ### Update Cache to struct in Command Step Source: https://github.com/buildkite/buildkite-sdk/blob/main/docs/v0.0.4-breaking-changes.md The Cache field is no longer an interface and is now a struct. Use String, StringArray, or CacheObject fields within the struct to define cache behavior. ```go // String step := buildkite.CommandStep{ Cache: &buildkite.Cache{ String: buildkite.Value("path"), }, } ``` ```go // String Array step := buildkite.CommandStep{ Cache: &buildkite.Cache{ StringArray: []string{"one","two"}, }, } ``` ```go // Object step := buildkite.CommandStep{ Cache: &buildkite.Cache{ Cache: &buildkite.CacheObject{ Paths: []string{"one", "two"}, Size: buildkite.Value("size"), Name: buildkite.Value("name"), }, }, } ``` -------------------------------- ### Update ContinueOnFailure to Struct in WaitStep Source: https://github.com/buildkite/buildkite-sdk/blob/main/docs/v0.0.4-breaking-changes.md The `ContinueOnFailure` field in `WaitStep` is now a struct named `WaitStepContinueOnFailure`. Set its value using either the `Bool` or `String` field. ```go // Bool step := buildkite.WaitStep{ ContinueOnFailure: &buildkite.WaitStepContinueOnFailure{ Bool: buildkite.Value(true), }, } ``` ```go // String step := buildkite.WaitStep{ ContinueOnFailure: &buildkite.WaitStepContinueOnFailure{ String: buildkite.Value("true"), }, } ``` -------------------------------- ### Update Command to struct in Command Step Source: https://github.com/buildkite/buildkite-sdk/blob/main/docs/v0.0.4-breaking-changes.md The Command field is no longer a string and is now a struct named CommandStepCommand. Use the String or StringArray field within the struct. ```go // String step := buildkite.CommandStep{ Command: &buildkite.CommandStepCommand{ String: buildkite.Value("run.sh"), } } ``` ```go // String Array step := buildkite.CommandStep{ Command: &buildkite.CommandStepCommand{ StringArray: []string{"one","two"}, } } ``` -------------------------------- ### Update SoftFail Type to SoftFail Struct Source: https://github.com/buildkite/buildkite-sdk/blob/main/docs/v0.0.4-breaking-changes.md The `SoftFail` field is now a struct named `SoftFail`. It supports both boolean and list-based configurations for soft failures. ```go // Simple step := buildkite.CommandStep{ SoftFail: &buildkite.SoftFail{ SoftFailEnum: &buildkite.SoftFailEnum{ Bool: buildkite.Value(true), }, }, } ``` ```go // List step := buildkite.CommandStep{ SoftFail: &buildkite.SoftFail{ SoftFailList: []buildkite.SoftFailObject{ { ExitStatus: &buildkite.SoftFailObjectExitStatus{ Int: buildkite.Value(1), }, }, }, }, } ``` -------------------------------- ### Update ArtifactPaths to struct in Command Step Source: https://github.com/buildkite/buildkite-sdk/blob/main/docs/v0.0.4-breaking-changes.md The ArtifactPaths field is no longer a []string and is now a struct named CommandStepArtifactPaths. Use String or StringArray fields within the struct. ```go // String step := buildkite.CommandStep{ ArtifactPaths: &buildkite.CommandStepArtifactPaths{ String: buildkite.Value("path"), }, } ``` ```go // StringArray step := buildkite.CommandStep{ ArtifactPaths: &buildkite.CommandStepArtifactPaths{ StringArray: []string{"one","two"}, }, } ``` -------------------------------- ### Update Commands to struct in Command Step Source: https://github.com/buildkite/buildkite-sdk/blob/main/docs/v0.0.4-breaking-changes.md The Commands field is no longer a string and is now a struct named CommandStepCommand. Use the String or StringArray field within the struct. ```go // String step := buildkite.CommandStep{ Commands: &buildkite.CommandStepCommand{ String: buildkite.Value("run.sh"), } } ``` ```go // String Array step := buildkite.CommandStep{ Commands: &buildkite.CommandStepCommand{ StringArray: []string{"one","two"}, } } ``` -------------------------------- ### Update DependsOn to Struct in GroupStep Source: https://github.com/buildkite/buildkite-sdk/blob/main/docs/v0.0.4-breaking-changes.md The `DependsOn` field in `GroupStep` is no longer an interface and now requires a struct. Provide a single step name as a string or a list of dependencies. ```go singleValue := "step" step := buildkite.GroupStep{ DependsOn: &buildkite.DependsOn{ String: buildkite.Value("step"), } } ``` ```go step := buildkite.GroupStep{ DependsOn: []buildkite.DependsOnListItem{ {String: buildkite.Value("one")}, { DependsOnList: &buildkite.DependsOnListObject{ Step: buildkite.Value("two"), }, } } } ``` -------------------------------- ### Update AllowDependencyFailure to struct in Command Step Source: https://github.com/buildkite/buildkite-sdk/blob/main/docs/v0.0.4-breaking-changes.md The AllowDependencyFailure field is no longer a bool and is now a struct. Use the Bool or String field within the struct to set the value. ```go // Boolean step := buildkite.CommandStep{ AllowDependencyFailure: &buildkite.AllowDependencyFailure{ Bool: buildkite.Value(true), } } ``` ```go // String step := buildkite.CommandStep{ AllowDependencyFailure: &buildkite.AllowDependencyFailure{ String: buildkite.Value("true"), } } ``` -------------------------------- ### Update AllowDependencyFailure to Struct in BlockStep Source: https://github.com/buildkite/buildkite-sdk/blob/main/docs/v0.0.4-breaking-changes.md The `AllowDependencyFailure` field in `BlockStep` is now a struct. Use `buildkite.Value` for boolean or string representations. ```go step := buildkite.BlockStep{ AllowDependencyFailure: &buildkite.AllowDependencyFailure{ Bool: buildkite.Value(true), } } ``` ```go step := buildkite.BlockStep{ AllowDependencyFailure: &buildkite.AllowDependencyFailure{ String: buildkite.Value("true"), } } ``` -------------------------------- ### Update Branches to Struct in WaitStep Source: https://github.com/buildkite/buildkite-sdk/blob/main/docs/v0.0.4-breaking-changes.md The `Branches` field in `WaitStep` is now a struct named `Branches`. It accepts a single string value or an array of strings. ```go step := buildkite.WaitStep{ Branches: &buildkite.Branches{ String: buildkite.Value("one"), } } ``` ```go listValues := []string{"one","two"} step := buildkite.WaitStep{ Branches: &buildkite.Branches{ StringArray: listValues, } } ``` -------------------------------- ### Update Skip to Struct in TriggerStep Source: https://github.com/buildkite/buildkite-sdk/blob/main/docs/v0.0.4-breaking-changes.md The `Skip` field in `TriggerStep` is now a struct named `Skip`. Set its value using either the `Bool` or `String` field. ```go // Bool step := buildkite.TriggerStep{ Skip: &buildkite.Skip{ Bool: buildkite.Value(true), } } ``` ```go // String step := buildkite.TriggerStep{ Skip: &buildkite.Skip{ String: buildkite.Value("true"), } } ``` -------------------------------- ### Update DependsOn to struct in Command Step Source: https://github.com/buildkite/buildkite-sdk/blob/main/docs/v0.0.4-breaking-changes.md The DependsOn field is no longer an interface and is now a struct. Use String or DependsOnList fields within the struct to define dependencies. ```go singleValue := "step" step := buildkite.CommandStep{ DependsOn: &buildkite.DependsOn{ String: buildkite.Value("step"), } } ``` ```go step := buildkite.CommandStep{ DependsOn: []buildkite.DependsOnListItem{ {String: buildkite.Value("one")}, { DependsOnList: &buildkite.DependsOnListObject{ Step: buildkite.Value("two"), }, } } } ``` -------------------------------- ### Update AllowDependencyFailure to Struct in WaitStep Source: https://github.com/buildkite/buildkite-sdk/blob/main/docs/v0.0.4-breaking-changes.md The `AllowDependencyFailure` field in `WaitStep` is now a struct. Use either the `Bool` or `String` field within the struct to set its value. ```go // Boolean step := buildkite.WaitStep{ AllowDependencyFailure: &buildkite.AllowDependencyFailure{ Bool: buildkite.Value(true), } } ``` ```go // String step := buildkite.WaitStep{ AllowDependencyFailure: &buildkite.AllowDependencyFailure{ String: buildkite.Value("true"), } } ``` -------------------------------- ### Update Retry Type to CommandStepRetry Source: https://github.com/buildkite/buildkite-sdk/blob/main/docs/v0.0.4-breaking-changes.md The `Retry` field is now a struct named `CommandStepRetry`. This provides a more structured way to define automatic retries. ```go // Automatic step := buildkite.CommandStep{ Retry: &buildkite.CommandStepRetry{ Automatic: &buildkite.CommandStepAutomaticRetry{ AutomaticRetryList: buildkite.Value([]buildkite.AutomaticRetry{ { Limit: buildkite.Value(1), }, }), }, }, } ``` -------------------------------- ### Update Agents field to struct in Command Step Source: https://github.com/buildkite/buildkite-sdk/blob/main/docs/v0.0.4-breaking-changes.md The Agents field is no longer a map[string]interface{} and is now a struct. Use AgentsList or AgentsObject to define agents. ```go // List step := buildkite.CommandStep{ Agents: &buildkite.Agents{ AgentsList: buildkite.Value([]string{"one","two"}) } } ``` ```go // Object step := buildkite.CommandStep{ Agents: &buildkite.Agents{ AgentsObject: buildkite.Value(map[string]interface{}{ "one": "two", }) } } ``` -------------------------------- ### Update Branches to struct in Command Step Source: https://github.com/buildkite/buildkite-sdk/blob/main/docs/v0.0.4-breaking-changes.md The Branches field is no longer a []string and is now a struct named Branches. Use String or StringArray fields within the struct. ```go step := buildkite.CommandStep{ Branches: &buildkite.Branches{ String: buildkite.Value("one"), } } ``` ```go listValues := []string{"one","two"} step := buildkite.CommandStep{ Branches: &buildkite.Branches{ StringArray: listValues, } } ``` -------------------------------- ### Update Branches to Struct in TriggerStep Source: https://github.com/buildkite/buildkite-sdk/blob/main/docs/v0.0.4-breaking-changes.md The `Branches` field in `TriggerStep` is now a struct named `Branches`. It accepts a single string value or an array of strings. ```go step := buildkite.TriggerStep{ Branches: &buildkite.Branches{ String: buildkite.Value("one"), } } ``` ```go listValues := []string{"one","two"} step := buildkite.TriggerStep{ Branches: &buildkite.Branches{ StringArray: listValues, } } ``` -------------------------------- ### Update Branches to Struct in BlockStep Source: https://github.com/buildkite/buildkite-sdk/blob/main/docs/v0.0.4-breaking-changes.md The `Branches` field in `BlockStep` is now a struct. It accepts a single string value or a slice of strings for branch patterns. ```go step := buildkite.BlockStep{ Branches: &buildkite.Branches{ String: buildkite.Value("one"), } } ``` ```go listValues := []string{"one","two"} step := buildkite.BlockStep{ Branches: &buildkite.Branches{ StringArray: listValues, } } ``` -------------------------------- ### Update AllowDependencyFailure to Struct in TriggerStep Source: https://github.com/buildkite/buildkite-sdk/blob/main/docs/v0.0.4-breaking-changes.md The `AllowDependencyFailure` field in `TriggerStep` is now a struct. Use either the `Bool` or `String` field within the struct to set its value. ```go // Boolean step := buildkite.TriggerStep{ AllowDependencyFailure: &buildkite.AllowDependencyFailure{ Bool: buildkite.Value(true), } } ``` ```go // String step := buildkite.TriggerStep{ AllowDependencyFailure: &buildkite.AllowDependencyFailure{ String: buildkite.Value("true"), } } ``` -------------------------------- ### Update DependsOn to Struct in WaitStep Source: https://github.com/buildkite/buildkite-sdk/blob/main/docs/v0.0.4-breaking-changes.md The `DependsOn` field in `WaitStep` is now a struct. It can be defined as a single string value or a list of items. ```go step := buildkite.WaitStep{ DependsOn: &buildkite.DependsOn{ String: buildkite.Value("step"), } } ``` ```go step := buildkite.WaitStep{ DependsOn: []buildkite.DependsOnListItem{ {String: buildkite.Value("one")}, { DependsOnList: &buildkite.DependsOnListObject{ Step: buildkite.Value("two"), }, } } } ```