Sergey Kulanov | 247c4e7 | 2016-10-17 16:43:29 +0300 | [diff] [blame] | 1 | def call(body) { |
| 2 | // evaluate the body block, and collect configuration into the object |
| 3 | def config = [:] |
| 4 | body.resolveStrategy = Closure.DELEGATE_FIRST |
| 5 | body.delegate = config |
| 6 | body() |
| 7 | |
Sergey Kulanov | 247c4e7 | 2016-10-17 16:43:29 +0300 | [diff] [blame] | 8 | |
| 9 | def dockerRepo = config.dockerRepo ?: "artifactory.mcp.mirantis.net:5001" |
Sergey Kulanov | 2202ad2 | 2016-10-18 17:14:12 +0300 | [diff] [blame] | 10 | def artifactoryUrl = config.artifactoryURL ?: "https://artifactory.mcp.mirantis.net/artifactory/projectcalico" |
Sergey Kulanov | 247c4e7 | 2016-10-17 16:43:29 +0300 | [diff] [blame] | 11 | |
| 12 | def nodeImage = config.nodeImage ?: "calico/node" |
| 13 | def nodeImageTag = config.nodeImageTag ?: "v0.20.0" |
| 14 | def nodeName = "${dockerRepo}/${nodeImage}:${nodeImageTag}" |
| 15 | |
| 16 | def ctlImage = config.ctlImage ?: "calico/ctl" |
| 17 | def ctlImageTag = config.ctlImageTag ?: "v0.20.0" |
| 18 | def ctlName = "${dockerRepo}/${ctlImage}:${ctlImageTag}" |
| 19 | |
Sergey Kulanov | 2202ad2 | 2016-10-18 17:14:12 +0300 | [diff] [blame] | 20 | // calico/build goes from {artifactoryUrl}/mcp/libcalico/ |
| 21 | def buildImage = config.buildImage ?: "${artifactoryUrl}/mcp/libcalico/lastbuild".toURL().text.trim() |
| 22 | // calico/felix goes from {artifactoryUrl}/mcp/felix/ |
| 23 | def felixImage = config.felixImage ?: "${artifactoryUrl}/mcp/felix/lastbuild".toURL().text.trim() |
Sergey Kulanov | 247c4e7 | 2016-10-17 16:43:29 +0300 | [diff] [blame] | 24 | |
Sergey Kulanov | 2202ad2 | 2016-10-18 17:14:12 +0300 | [diff] [blame] | 25 | def confdBuildId = config.confdBuildId ?: "${artifactoryUrl}/mcp/confd/lastbuild".toURL().text.trim() |
| 26 | def confdUrl = config.confdUrl ?: "${artifactoryUrl}/mcp/confd/confd-${confdBuildId}" |
Sergey Kulanov | 247c4e7 | 2016-10-17 16:43:29 +0300 | [diff] [blame] | 27 | |
Sergey Kulanov | 2202ad2 | 2016-10-18 17:14:12 +0300 | [diff] [blame] | 28 | def birdBuildId = config.birdBuildId ?: "${artifactoryUrl}/mcp/calico-bird/lastbuild".toURL().text.trim() |
| 29 | def birdUrl = config.birdUrl ?: "${artifactoryUrl}/mcp/calico-bird/bird-${birdBuildId}" |
| 30 | def bird6Url = config.bird6Url ?: "${artifactoryUrl}/mcp/calico-bird/bird6-${birdBuildId}" |
| 31 | def birdclUrl = config.birdclUrl ?: "${artifactoryUrl}/mcp/calico-bird/birdcl-${birdBuildId}" |
Sergey Kulanov | 247c4e7 | 2016-10-17 16:43:29 +0300 | [diff] [blame] | 32 | |
Sergey Kulanov | 00d7434 | 2016-10-24 15:22:11 +0300 | [diff] [blame] | 33 | def gitCommit = sh(returnStdout: true, script: "git rev-parse --short HEAD").trim() |
Sergey Kulanov | 247c4e7 | 2016-10-17 16:43:29 +0300 | [diff] [blame] | 34 | |
| 35 | def build = "${config.containersBuildId}-${gitCommit}" |
| 36 | |
| 37 | // return values |
Sergey Kulanov | 2202ad2 | 2016-10-18 17:14:12 +0300 | [diff] [blame] | 38 | def calicoNodeImageRepo = "${dockerRepo}/${nodeImage}" |
| 39 | def calicoCtlImageRepo = "${dockerRepo}/${ctlImage}" |
| 40 | def calicoVersion = "${nodeImageTag}-${build}" |
| 41 | def ctlContainerName = "${ctlName}-${build}" |
| 42 | def nodeContainerName = "${nodeName}-${build}" |
Sergey Kulanov | 247c4e7 | 2016-10-17 16:43:29 +0300 | [diff] [blame] | 43 | |
| 44 | // Start build section |
| 45 | |
| 46 | stage ('Build calico/ctl image'){ |
| 47 | sh """ |
Sergey Kulanov | d7ea0fe | 2016-11-05 14:00:20 +0200 | [diff] [blame^] | 48 | make calico/ctl \ |
Sergey Kulanov | 2202ad2 | 2016-10-18 17:14:12 +0300 | [diff] [blame] | 49 | CTL_CONTAINER_NAME=${ctlContainerName} \ |
Sergey Kulanov | 247c4e7 | 2016-10-17 16:43:29 +0300 | [diff] [blame] | 50 | BUILD_CONTAINER_NAME=${buildImage} \ |
| 51 | BIRDCL_URL=${birdclUrl} |
| 52 | """ |
| 53 | } |
| 54 | |
Sergey Kulanov | 00a84f6 | 2016-10-31 14:36:18 +0200 | [diff] [blame] | 55 | // libcalico project should be already checkouted to |
| 56 | // calico_node/node_share/libcalico |
Sergey Kulanov | 247c4e7 | 2016-10-17 16:43:29 +0300 | [diff] [blame] | 57 | stage('Build calico/node'){ |
| 58 | sh """ |
Sergey Kulanov | d7ea0fe | 2016-11-05 14:00:20 +0200 | [diff] [blame^] | 59 | make calico/node \ |
Sergey Kulanov | 2202ad2 | 2016-10-18 17:14:12 +0300 | [diff] [blame] | 60 | NODE_CONTAINER_NAME=${nodeContainerName} \ |
Sergey Kulanov | 00a84f6 | 2016-10-31 14:36:18 +0200 | [diff] [blame] | 61 | NODE_CONTAINER_BUILD_ARGS='\ |
| 62 | --build-arg LIBCALICO_REPO=file:///tmp/node_share/libcalico \ |
| 63 | --build-arg LIBCALICO_VER=mcp' \ |
Sergey Kulanov | 247c4e7 | 2016-10-17 16:43:29 +0300 | [diff] [blame] | 64 | BUILD_CONTAINER_NAME=${buildImage} \ |
| 65 | FELIX_CONTAINER_NAME=${felixImage} \ |
| 66 | CONFD_URL=${confdUrl} \ |
| 67 | BIRD_URL=${birdUrl} \ |
| 68 | BIRD6_URL=${bird6Url} \ |
| 69 | BIRDCL_URL=${birdclUrl} |
| 70 | """ |
| 71 | } |
| 72 | |
| 73 | |
Sergey Kulanov | 2202ad2 | 2016-10-18 17:14:12 +0300 | [diff] [blame] | 74 | dir("artifacts"){ |
| 75 | // Save the last build ID |
| 76 | writeFile file: "lastbuild", text: "${build}" |
| 77 | // Create config yaml for Kargo |
| 78 | writeFile file: "calico-containers-${build}.yaml", |
| 79 | text: """\ |
| 80 | calico_node_image_repo: ${calicoNodeImageRepo} |
| 81 | calicoctl_image_repo: ${calicoCtlImageRepo} |
| 82 | calico_version: ${calicoVersion} |
| 83 | """.stripIndent() |
| 84 | } // dir artifacts |
Sergey Kulanov | 247c4e7 | 2016-10-17 16:43:29 +0300 | [diff] [blame] | 85 | |
| 86 | return [ |
Sergey Kulanov | 2202ad2 | 2016-10-18 17:14:12 +0300 | [diff] [blame] | 87 | CTL_CONTAINER_NAME:"${ctlContainerName}", |
| 88 | NODE_CONTAINER_NAME:"${nodeContainerName}", |
Sergey Kulanov | 247c4e7 | 2016-10-17 16:43:29 +0300 | [diff] [blame] | 89 | CALICO_NODE_IMAGE_REPO:"${calicoNodeImageRepo}", |
| 90 | CALICOCTL_IMAGE_REPO:"${calicoCtlImageRepo}", |
| 91 | CALICO_VERSION: "${calicoVersion}" |
| 92 | ] |
| 93 | |
| 94 | } |