Skip to content

Instantly share code, notes, and snippets.

@alisade
Created April 1, 2021 15:07
Show Gist options
  • Select an option

  • Save alisade/42c681998d2e5d7867e80be645b6913f to your computer and use it in GitHub Desktop.

Select an option

Save alisade/42c681998d2e5d7867e80be645b6913f to your computer and use it in GitHub Desktop.

Revisions

  1. alisade created this gist Apr 1, 2021.
    55 changes: 55 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,55 @@
    // Job == agent-build_pipeline
    // build agent for linux/windows
    currentBuild.description = env.TAG
    def WORKER='worker-large'
    def OS = [ 'redhat', 'debian' ]
    def ARCH = [ '64' ]
    def pipeline_branches = [:]
    def JB='./jenkins/build'
    def jbuild = { sh "bash ${JB}/build.sh" }
    def provision = { sh "bash ${JB}/provision.sh" }
    def sign = { sh "bash ${JB}/sign.sh" }
    def cleanup = { sh "bash ${JB}/cleanup.sh" }
    switch ( env.TAG ) {
    case ~ /.*windows.*/ :
    WORKER='worker-windows'
    OS = ['windows']
    ARCH = [ '64' ]
    jbuild = {}
    provision = { bat "${JB}/provision.bat" }
    sign = {}
    cleanup = {}
    break
    }
    for ( os in OS )
    for ( arch in ARCH )
    pipeline_branches["${os}-${arch}"] = build_agent(os, arch, env.TAG,
    jbuild, provision, sign,
    cleanup, WORKER)
    parallel pipeline_branches
    def build_agent(os, arch, tag, jbuild, provision, sign, cleanup, worker) {
    return {
    node(worker) {
    withEnv(["TAG=${tag}",
    "OS=${os}",
    "ARCH=${arch}"
    ]) {
    stage("${os}-${arch}-checkout") {
    checkout scm
    }
    stage("${os}-${arch}-cleanup") {
    cleanup()
    }
    stage("${os}-${arch}-build") {
    jbuild()
    }
    stage("${os}-${arch}-provision") {
    provision()
    }
    stage("${os}-${arch}-sign") {
    sign()
    }
    }
    }
    }
    }