All Downloads are FREE. Search and download functionalities are using the official Maven repository.

.bamboo.specs.extension.bamboo-specs-extension.1.2.6.source-code.TasksExtension.kt Maven / Gradle / Ivy

There is a newer version: 1.3.18
Show newest version
package com.atlassian.bamboo.specs.extension

import com.atlassian.bamboo.specs.api.builders.AtlassianModule
import com.atlassian.bamboo.specs.api.builders.task.AnyTask
import com.atlassian.bamboo.specs.api.builders.task.Task
import com.atlassian.bamboo.specs.builders.task.*

fun VcsCheckoutTask.checkout(name: String, path: String? = null): VcsCheckoutTask {
    val checkoutItem = CheckoutItem()
    checkoutItem.repository(name)
    if (path != null)
        checkoutItem.path(path)
    this.checkoutItems(checkoutItem)
    return this
}

fun VcsCheckoutTask.checkoutDefault(path: String? = null): VcsCheckoutTask {
    val checkoutItem = CheckoutItem()
    checkoutItem.defaultRepository()
    if (path != null)
        checkoutItem.path(path)
    this.checkoutItems(checkoutItem)
    return this
}

fun ScriptTask.environmentVariables(vararg variables: Pair): ScriptTask = environmentVariables(variables.toMap())

fun ScriptTask.environmentVariables(variables: Map): ScriptTask =
        environmentVariables(variables.map { "${it.key}=${it.value}" }.joinToString(" "))

fun ArtifactDownloaderTask.allArtifacts(path: String? = null) {
    val downloadItem = DownloadItem()
    downloadItem.allArtifacts(true)
    if (path != null)
        downloadItem.path(path)
    this.artifacts(downloadItem)
}

fun ArtifactDownloaderTask.artifact(name: String, path: String? = null) {
    val downloadItem = DownloadItem()
    downloadItem.artifact(name)
    if (path != null)
        downloadItem.path(path)
    this.artifacts(downloadItem)
}

internal fun > taskInitialisation(taskConstructor: () -> T, description: String? = null, enabled: Boolean? = null, init: SpecsDsl = {}): T {
    val task = taskConstructor()
    if (description != null)
        task.description(description)
    if (enabled != null)
        task.enabled(enabled)
    task.init()
    return task
}

internal fun taskInitialisation(taskType: String, description: String? = null, enabled: Boolean? = null, init: SpecsDsl = {}): AnyTask =
        taskInitialisation({ AnyTask(AtlassianModule(taskType)) }, description, enabled, init)




© 2015 - 2024 Weber Informatics LLC | Privacy Policy