Jenkinsfile
author Jan Vrany <jan.vrany@fit.cvut.cz>
Mon, 14 Nov 2016 23:00:13 +0000
branchfeature-block-in-context
changeset 80 c213d491e876
parent 74 57edfcce2a40
child 105 983a637074e6
permissions -rw-r--r--
Added feature branch "feature-block-in-context"

/*
 * Run default pipeline. See `pipeline.groovy for details.
 */

def pipeline;

def branch() {
    if (env.BRANCH_NAME == null) {
        return scm.getBranch();
    } else {
        return env.BRANCH_NAME;
    }
}

stage ( "Load Pipeline") {
    node {
        /*
         * Do not use default workspace here as checkout
         * would erase all contents. Use a dedicated
         * workspace instead
         */
        ws ("workspace/${env.JOB_NAME}@loadpipeline") {
            sshagent([ scm.getCredentialsId() ]) {
                sh  """
                    if [ -f pipeline.groovy ]; then
                        hg pull ${scm.getSource()}
                    else
                        hg clone ${scm.getSource()} .
                    fi
                    hg up ${branch()}
                    """
            }
            pipeline = load "pipeline.groovy"
        }
    }
}

pipeline.build()
pipeline.test()