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

javaposse.jobdsl.dsl.helpers.step.CopyArtifactContext.groovy Maven / Gradle / Ivy

There is a newer version: 1.22-rxd-2
Show newest version
package javaposse.jobdsl.dsl.helpers.step

import javaposse.jobdsl.dsl.helpers.Context


class CopyArtifactContext implements Context {
    String selectedSelector
    boolean fallback
    String permalinkName
    int buildNumber
    String parameterName

    private void ensureFirst() {
        if (selectedSelector != null) {
            throw new IllegalStateException("Only one selector can be chosen")
        }
    }
    /**
     * Upstream build that triggered this job
     * @arg fallback Use "Last successful build" as fallback
     * @return
     */
    def upstreamBuild(boolean fallback = false) {
        ensureFirst()
        this.fallback = fallback
        selectedSelector = 'TriggeredBuild'
    }

    /**
     * Latest successful build
     * @return
     */
    def latestSuccessful() {
        ensureFirst()
        selectedSelector = 'StatusBuild'
    }
    /**
     * Latest saved build (marked "keep forever")
     * @return
     */
    def latestSaved() {
        ensureFirst()
        selectedSelector = 'SavedBuild'
    }
    /**
     * Specified by permalink
     * @param linkName Values like lastBuild, lastStableBuild
     * @return
     */
    def permalink(String linkName) {
        ensureFirst()
        selectedSelector = 'PermalinkBuild'
        permalinkName = linkName
    }

    /**
     * Specific Build
     * @param buildNumber
     * @return
     */
    def buildNumber(int buildNumber) {
        ensureFirst()
        selectedSelector = 'SpecificBuild'
        this.buildNumber = buildNumber
    }

    /**
     * Copy from WORKSPACE of latest completed build
     * @return
     */
    def workspace() {
        ensureFirst()
        selectedSelector = 'Workspace'
    }

    /**
     * Specified by build parameter
     * @param parameterName
     * @return
     */
    def buildParameter(String parameterName) {
        ensureFirst()
        selectedSelector = 'ParameterizedBuild'
        this.parameterName = parameterName
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy