Jenkinsfile
author Jan Vrany <jan.vrany@fit.cvut.cz>
Mon, 02 Apr 2018 07:32:49 +0100
changeset 157 1dc7921d4355
parent 151 ce9d05ba9205
permissions -rw-r--r--
Rakefiles: fixed `cp_rx()` extension to work with Ruby 2.5 ...which removed `fu_check_options()` from `FileUtils` in favor of new syntax. (grafted from 23fae3bd033e10bf120d6488bc2866f1a2d1a195)

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

def pipeline;

/*
 * A helper function to return a branch to build.
 *
 * For normal jobs this is the value of 'Branch' field from SCM configuration.
 * For multibranch jobs, this is the value of BRANCH_NAME environment variable.
 *
 * This is the same as build() function in `pipeline.groovy` and should be kept
 * in sync. We cannot use the one there as we yet have to load it.
 */
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 --ssh ssh ${scm.getSource()}
                    else
                        hg clone --ssh ssh ${scm.getSource()} .
                    fi
                    hg up ${branch()}
                    """
            }
            pipeline = load "pipeline.groovy"
        }
    }
}

/*
 * Set the branch to build to make sure it's in sync
 */
pipeline.branch = branch()

/*
 * If we're building a 'default' branch, run "integration" pipeline. Otherwise,
 * run normal "build" pipeline, assuming this build is just a test build for
 * some feature-in-progress. If different logic is needed, then make a branch
 * and modify this file
 */
if ( branch().equals("default") ) {
    pipeline.integration()
} else {
    pipeline.build()
}