Swiftpack.co - aaronsky/buildkite-swift as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
A Swift library for the Buildkite REST and GraphQL APIs
.package(url: "https://github.com/aaronsky/buildkite-swift.git", from: "0.1.0")


Build Status

A Swift library and client for the Buildkite REST and GraphQL APIs.


Add the dependency to your Package.swift file:

let package = Package(
    name: "myproject",
    dependencies: [
        .package(url: "https://github.com/aaronsky/buildkite-swift.git", from: "0.2.0"),
    targets: [
            name: "myproject",
            dependencies: ["Buildkite"]),

As an example, here is a way you can use the closure-based interface to list all pipelines:

import Buildkite

let client = BuildkiteClient()
client.token = "..." // Your scoped Buildkite API access token
client.send(.pipelines(in: "buildkite")) { result in
    do {
        let response = try result.get()
        let pipelines = response.content
    } catch {

You can also use Combine, if you'd like!

import Buildkite

let client = BuildkiteClient()
client.token = "..." // Your scoped Buildkite API access token

var cancellables: Set<AnyCancellable> = []
client.sendPublisher(.pipelines(in: "buildkite"))
    .sink(receiveCompletion: { _ in }) { pipelines in
    }.store(in: &cancellables)

If you're using Swift 5.5 or Xcode 13, and are shipping on a supported OS, you can even use the new async/await syntax:

import Buildkite

let client = BuildkiteClient()
client.token = "..." // Your scoped Buildkite API access token

let response = try await client.send(.pipelines(in: "buildkite"))
let pipelines = response.content


The entire publicly documented REST API surface is supported by this package.


GraphQL support is present, but currently rudimentary. For example, here's what the same query as above would look like in GraphQL:

import Foundation
import Buildkite

let client = BuildkiteClient()
client.token = "..."

let query = """
query MyPipelines($first: Int!) {
    organization(slug: "buildkite") {
        pipelines(first: $first) {
            edges {
                node {

struct MyPipeline: Codable {
    var organization: Organization?

    struct Organization: Codable {
        var pipelines: Pipelines

        struct Pipelines: Codable {
            var edges: [PipelineEdge]

            struct PipelineEdge: Codable {
                var node: Pipeline

                struct Pipeline: Codable {
                    var name: String
                    var uuid: UUID

var cancellables: Set<AnyCancellable> = []
let pipeline: MyPipeline = try await client.sendQuery(GraphQL(rawQuery: query, 
                                                              variables: ["first": 30])

The helper method sendQuery can be used to automatically extract the data from a GraphQL response, without having to juggle HTTP, decoding and schema errors in separate calls. You can still use any of the send or sendPublisher methods to process a GraphQL query, if you require the response data as well.



Buildkite for Swift is released under the BSD-2 license. See LICENSE for details.


Stars: 2
Last commit: 4 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Submit a free job ad (while I'm testing this). The analytics numbers for this website are here.

Release Notes

1 year ago

This is the first minor-version release of this package. While not yet committing to the stability guarantees of a a major version, this marks a period of considered stability before making changes to the API.

This release includes a small change to the data type returned by the GraphQL resource. After some research and discussion with members of the Buildkite team, it was determined that the GraphQL API offered by Buildkite is not capable of responding with data and errors simultaneously as is outlined in the specification. This means that you can write code that maps on the variant returned by GraphQL.Content, which works well with either the Combine API or the Result returned by the closure API.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics