Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (C) 2023 Slack Technologies, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:UseSerializers(JsonObjectAsMapSerializer::class, JsonElementKamlSerializer::class)
package slack.cli.buildkite
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.UseSerializers
import kotlinx.serialization.json.JsonArray
import kotlinx.serialization.json.JsonObject
/*
* Generated with https://app.quicktype.io/ using
* https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json.
*
* Modifications after:
* - Convert sealed classes to sealed interfaces
* - Convert sealed subtypes to value classes or data objects. This is important for the yaml to actually serialize
* correctly, otherwise there will be intermediate "value" levels.
* - Add @file:UseSerializers for JsonObjectAsMapSerializer and JsonElementKamlSerializer so that we can serialize
* the json types.
* - Change ExitStatusUnion.DoubleValue to a LongValue as exit codes aren't doubles.
* - Add invoke operators for all sealed interfaces to make it easier to construct the data classes.
* - Add GroupStep.WaitStepValue for inline Wait.
* - Add GroupStep.BlockStepValue for inline BlockStep.
* - Renames
* - `CommandStep` -> `ScriptStep`
* - `PurpleStepValue` -> `CommandStepValue`
* - `PurpleStep` -> `CommandStep`
* - `PurpleGithubCommitStatus` -> `GithubCommitStatus`
* - `PurpleGithubCheck` -> `GithubCheck`
* - `StickySlack` -> `SlackNotification`
* - `StickySlack.PurpleSlackValue` -> `StickySlack.Multi`
* - `StickySlack.StringValue` -> `StickySlack.Conversation`
* - `PurpleSlack` -> `MultiChannelMessage`
* - `PurpleBranches` -> `Branches`
* - `Coordinat` -> `GithubNotification`
* - `PurpleType` -> `StepType`
* - `NotifyElement` -> `Notification`
* - `NotifyElement.EnumValue` -> `NotifyElement.GitHub`
* - `NotifyClass` -> `ExternalNotification`
* - `CoordinateClass` -> `Pipeline`
*
* - Consolidations
* - `IndigoSlack` -> X (SlackNotification)
* - `IndecentSlack` -> X (GithubCommitStatus)
* - `FluffySlack` -> X (MultiChannelMessage)
* - `TentacledSlack` -> X (MultiChannelMessage)
* - `FluffyGithubCheck` -> X (GithubCheck)
* - `FluffyGithubCommitStatus` -> X (GithubCommitStatus)
* - `TentacledGithubCheck` -> X (GithubCheck)
* - `TentacledGithubCommitStatus` -> X (GithubCommitStatus)
* - `ScriptNotify.EnumValue` -> X (Notification)
* - `ScriptNotify.PurpleNotifyValue` -> X (Notification)
* - `PurpleNotify` -> X (ExternalNotification)`
* - `NestedBlockStepNotify` -> X (Notification)`
* - `FluffyNotifyValue` -> X (ExternalNotification)`
*/
@Serializable
public data class Pipeline(
/** A list of steps */
val steps: List,
val agents: Agents? = null,
val env: JsonObject? = null,
val notify: List? = null,
)
@Serializable
public sealed interface Agents {
@JvmInline
@Serializable
public value class AnythingMapValue(public val value: JsonObject) : Agents
@JvmInline
@Serializable
public value class StringArrayValue(public val value: List) : Agents
public companion object {
public operator fun invoke(value: JsonObject): Agents = AnythingMapValue(value)
public operator fun invoke(value: List): Agents = StringArrayValue(value)
}
}
/** Array of notification options for this step */
@Serializable
public sealed interface Notification {
@JvmInline
@Serializable
public value class GitHub(public val value: GithubNotification) : Notification
@JvmInline
@Serializable
public value class External(public val value: ExternalNotification) : Notification
public companion object {
public operator fun invoke(value: GithubNotification): Notification = GitHub(value)
public operator fun invoke(value: ExternalNotification): Notification = External(value)
}
}
@Serializable
public data class ExternalNotification(
val email: String? = null,
@SerialName("if") val notifyIf: String? = null,
@SerialName("basecamp_campfire") val basecampCampfire: String? = null,
val slack: SlackNotification? = null,
val webhook: String? = null,
@SerialName("pagerduty_change_event") val pagerdutyChangeEvent: String? = null,
@SerialName("github_commit_status") val githubCommitStatus: GithubCommitStatus? = null,
@SerialName("github_check") val githubCheck: GithubCheck? = null,
)
@Serializable
public data class GithubCheck(
/** GitHub commit status name */
val context: String? = null
)
@Serializable
public data class GithubCommitStatus(
/** GitHub commit status name */
val context: String? = null
)
@Serializable
public sealed interface SlackNotification {
@Serializable
@JvmInline
public value class Multi(public val value: MultiChannelMessage) : SlackNotification
@Serializable
@JvmInline
public value class Conversation(public val value: String) : SlackNotification
}
@Serializable
public data class MultiChannelMessage(
val channels: List? = null,
val message: String? = null,
)
@Serializable
public enum class GithubNotification(public val value: String) {
@SerialName("github_check") GithubCheck("github_check"),
@SerialName("github_commit_status") GithubCommitStatus("github_commit_status"),
}
@Serializable
public sealed interface GroupStep : Keyable {
@Serializable
@JvmInline
public value class AnythingArrayValue(public val value: JsonArray) : GroupStep {
override val key: String?
get() = null
}
@Serializable
@JvmInline
public value class BoolValue(public val value: Boolean) : GroupStep {
override val key: String?
get() = null
}
@Serializable
@JvmInline
public value class DoubleValue(public val value: Double) : GroupStep {
override val key: String?
get() = null
}
@Serializable
@JvmInline
public value class IntegerValue(public val value: Long) : GroupStep {
override val key: String?
get() = null
}
@Serializable
@JvmInline
public value class NestedBlockStepClassValue(public val value: NestedBlockStepClass) :
GroupStep, Keyable by value
@Serializable
@JvmInline
public value class WaitStepValue(public val value: Wait) : GroupStep, Keyable by value
@Serializable
@JvmInline
public value class BlockStepValue(public val value: BlockStep) : GroupStep, Keyable by value
@Serializable
@JvmInline
public value class CommandStepValue(public val value: CommandStep) : GroupStep, Keyable by value
@Serializable
@JvmInline
public value class StringValue(public val value: String) : GroupStep {
override val key: String?
get() = null
}
@Serializable
public data object NullValue : GroupStep {
override val key: String?
get() = null
}
public companion object {
public operator fun invoke(value: JsonArray): GroupStep = AnythingArrayValue(value)
public operator fun invoke(value: Boolean): GroupStep = BoolValue(value)
public operator fun invoke(value: Double): GroupStep = DoubleValue(value)
public operator fun invoke(value: Long): GroupStep = IntegerValue(value)
public operator fun invoke(value: NestedBlockStepClass): GroupStep =
NestedBlockStepClassValue(value)
public operator fun invoke(value: String): GroupStep = StringValue(value)
public operator fun invoke(value: Wait): GroupStep = WaitStepValue(value)
public operator fun invoke(value: BlockStep): GroupStep = BlockStepValue(value)
public operator fun invoke(value: CommandStep): GroupStep = CommandStepValue(value)
}
}
/** Waits for previous steps to pass before continuing */
@Serializable
public data class NestedBlockStepClass(
@SerialName("allow_dependency_failure") val allowDependencyFailure: Boolean? = null,
/** The label of the block step */
val block: Block? = null,
/** The state that the build is set to when the build is blocked by this block step */
@SerialName("blocked_state") val blockedState: BlockedState? = null,
val branches: SimpleStringValue? = null,
@SerialName("depends_on") val dependsOn: DependsOn? = null,
val fields: List? = null,
val id: String? = null,
val identifier: String? = null,
@SerialName("if") val stepIf: String? = null,
override val key: String? = null,
val label: String? = null,
val name: String? = null,
val prompt: String? = null,
val type: NestedBlockStepType? = null,
/** The label of the input step */
val input: Input? = null,
val agents: Agents? = null,
/** The glob path/s of artifacts to upload once this step has finished running */
@SerialName("artifact_paths") val artifactPaths: SimpleStringValue? = null,
@SerialName("cancel_on_build_failing") val cancelOnBuildFailing: Boolean? = null,
/** The commands to run on the agent */
val command: Commands? = null,
/** The commands to run on the agent */
val commands: Commands? = null,
/**
* The maximum number of jobs created from this step that are allowed to run at the same time. If
* you use this attribute, you must also define concurrency_group.
*/
val concurrency: Long? = null,
/**
* A unique name for the concurrency group that you are creating with the concurrency attribute
*/
@SerialName("concurrency_group") val concurrencyGroup: String? = null,
/**
* Control command order, allowed values are 'ordered' (default) and 'eager'. If you use this
* attribute, you must also define concurrency_group and concurrency.
*/
@SerialName("concurrency_method") val concurrencyMethod: ConcurrencyMethod? = null,
val env: JsonObject? = null,
val matrix: MatrixUnion? = null,
/** Array of notification options for this step */
val notify: List? = null,
/** The number of parallel jobs that will be created based on this step */
val parallelism: Long? = null,
val plugins: Plugins? = null,
/** Priority of the job, higher priorities are assigned to agents */
val priority: Long? = null,
/** The conditions for retrying this step. */
val retry: Retry? = null,
/** The signature of the command step, generally injected by agents at pipeline upload */
val signature: Signature? = null,
val skip: Skip? = null,
@SerialName("soft_fail") val softFail: SoftFail? = null,
/** The number of minutes to time out a job */
@SerialName("timeout_in_minutes") val timeoutInMinutes: Long? = null,
val script: ScriptStep? = null,
/** Continue to the next steps, even if the previous group of steps fail */
@SerialName("continue_on_failure") val continueOnFailure: Boolean? = null,
/** Waits for previous steps to pass before continuing */
val wait: Wait? = null,
val waiter: Wait? = null,
/** Whether to continue the build without waiting for the triggered step to complete */
val async: Boolean? = null,
/** Properties of the build that will be created when the step is triggered */
val build: Build? = null,
/** The slug of the pipeline to create a build */
val trigger: Trigger? = null,
/** The name to give to this group of steps */
val group: String? = null,
/** A list of steps */
val steps: List? = null,
) : Keyable
/**
* - Which branches will include this step in their builds
* - The value of the option(s) that will be pre-selected in the dropdown
* - The glob path/s of artifacts to upload once this step has finished running
* - The commands to run on the agent
*/
@Serializable
public sealed interface SimpleStringValue {
@Serializable
@JvmInline
public value class ListValue(public val value: List) : SimpleStringValue
@Serializable
@JvmInline
public value class SingleValue(public val value: String) : SimpleStringValue
public companion object {
public operator fun invoke(value: List): SimpleStringValue = ListValue(value)
public operator fun invoke(value: String): SimpleStringValue = SingleValue(value)
public operator fun invoke(vararg values: String): SimpleStringValue =
ListValue(values.toList())
}
}
@Serializable
public sealed interface Block {
@Serializable @JvmInline public value class BlockStepValue(public val value: BlockStep) : Block
@Serializable @JvmInline public value class StringValue(public val value: String) : Block
}
@Serializable
public data class BlockStep(
@SerialName("allow_dependency_failure") val allowDependencyFailure: Boolean? = null,
/** The label of the block step */
val block: String? = null,
/** The state that the build is set to when the build is blocked by this block step */
@SerialName("blocked_state") val blockedState: BlockedState? = null,
val branches: SimpleStringValue? = null,
@SerialName("depends_on") val dependsOn: DependsOn? = null,
val fields: List? = null,
val id: String? = null,
val identifier: String? = null,
@SerialName("if") val blockStepIf: String? = null,
override val key: String? = null,
val label: String? = null,
val name: String? = null,
val prompt: String? = null,
val type: BlockType? = null,
) : Keyable
/** The state that the build is set to when the build is blocked by this block step */
@Serializable
public enum class BlockedState(public val value: String) {
@SerialName("failed") Failed("failed"),
@SerialName("passed") Passed("passed"),
@SerialName("running") Running("running"),
}
/** The step keys for a step to depend on */
@Serializable
public sealed interface DependsOn {
@Serializable @JvmInline public value class StringValue(public val value: String) : DependsOn
@Serializable
@JvmInline
public value class UnionArrayValue(public val value: List) : DependsOn
@Serializable public data object NullValue : DependsOn
public companion object {
public operator fun invoke(value: String): DependsOn = StringValue(value)
public operator fun invoke(vararg values: String): DependsOn =
invoke(values.toList().map(DependsOnElement::invoke))
public operator fun invoke(value: List): DependsOn = UnionArrayValue(value)
public operator fun invoke(value: Keyable): DependsOn = invoke(requireKey(value))
@Suppress("SpreadOperator")
public operator fun invoke(vararg values: Keyable): DependsOn =
invoke(*values.map { requireKey(it) }.toTypedArray())
@JvmName("invokeKeyableList")
public operator fun invoke(value: List): DependsOn =
invoke(value.map { DependsOnElement.invoke(requireKey(it)) })
private fun requireKey(keyable: Keyable): String {
return requireNotNull(keyable.key) {
"Key for step must not be null to depend on it: $keyable"
}
}
}
}
@Serializable
public sealed interface DependsOnElement {
@Serializable
@JvmInline
public value class DependsOnClassValue(public val value: DependsOnClass) : DependsOnElement
@Serializable
@JvmInline
public value class StringValue(public val value: String) : DependsOnElement
public companion object {
public operator fun invoke(value: DependsOnClass): DependsOnElement = DependsOnClassValue(value)
public operator fun invoke(value: String): DependsOnElement = StringValue(value)
}
}
@Serializable
public data class DependsOnClass(
@SerialName("allow_failure") val allowFailure: Boolean? = null,
val step: String? = null,
)
/** A list of input fields required to be filled out before unblocking the step */
@Serializable
public data class FieldElement(
/**
* The value that is pre-filled in the text field
*
* The value of the option(s) that will be pre-selected in the dropdown
*/
val default: SimpleStringValue? = null,
/** The explanatory text that is shown after the label */
val hint: String? = null,
/** The meta-data key that stores the field's input */
val key: String,
/** Whether the field is required for form submission */
val required: Boolean? = null,
/** The text input name */
val text: String? = null,
/** Whether more than one option may be selected */
val multiple: Boolean? = null,
val options: List