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 | |
Sergey Kulanov | 3a939c1 | 2016-11-28 11:54:35 +0200 | [diff] [blame] | 9 | // FIXME(skulanov): remove this after complete migration of calico jobs |
Sergey Kulanov | faae386 | 2016-11-28 13:27:36 +0200 | [diff] [blame] | 10 | // def dockerRepo = config.dockerRepo ?: "mcp-k8s.docker.mirantis.net" |
Sergey Kulanov | 3a939c1 | 2016-11-28 11:54:35 +0200 | [diff] [blame] | 11 | // def artifactoryUrl = config.artifactoryURL ?: "https://artifactory.mcp.mirantis.net/projectcalico" |
Sergey Kulanov | 6d9a4f8 | 2016-11-28 16:37:27 +0200 | [diff] [blame] | 12 | def dockerRepo = config.dockerRepo ?: "artifactory.mcp.mirantis.net:5001" |
Sergey Kulanov | 3a939c1 | 2016-11-28 11:54:35 +0200 | [diff] [blame] | 13 | def artifactoryUrl = config.artifactoryURL ?: "https://artifactory.mcp.mirantis.net/artifactory/projectcalico" |
Sergey Kulanov | 247c4e7 | 2016-10-17 16:43:29 +0300 | [diff] [blame] | 14 | |
| 15 | def nodeImage = config.nodeImage ?: "calico/node" |
Artem Panchenko | 4932b17 | 2016-11-08 19:06:03 +0200 | [diff] [blame] | 16 | def nodeImageTag = config.nodeImageTag ?: "v1.0.0-beta" |
Sergey Kulanov | 247c4e7 | 2016-10-17 16:43:29 +0300 | [diff] [blame] | 17 | def nodeName = "${dockerRepo}/${nodeImage}:${nodeImageTag}" |
| 18 | |
| 19 | def ctlImage = config.ctlImage ?: "calico/ctl" |
Artem Panchenko | 4932b17 | 2016-11-08 19:06:03 +0200 | [diff] [blame] | 20 | def ctlImageTag = config.ctlImageTag ?: "v1.0.0-beta" |
Sergey Kulanov | 247c4e7 | 2016-10-17 16:43:29 +0300 | [diff] [blame] | 21 | def ctlName = "${dockerRepo}/${ctlImage}:${ctlImageTag}" |
| 22 | |
Sergey Kulanov | 2202ad2 | 2016-10-18 17:14:12 +0300 | [diff] [blame] | 23 | // calico/build goes from {artifactoryUrl}/mcp/libcalico/ |
| 24 | def buildImage = config.buildImage ?: "${artifactoryUrl}/mcp/libcalico/lastbuild".toURL().text.trim() |
| 25 | // calico/felix goes from {artifactoryUrl}/mcp/felix/ |
| 26 | def felixImage = config.felixImage ?: "${artifactoryUrl}/mcp/felix/lastbuild".toURL().text.trim() |
Sergey Kulanov | 247c4e7 | 2016-10-17 16:43:29 +0300 | [diff] [blame] | 27 | |
Sergey Kulanov | 74910b6 | 2016-11-28 18:00:17 +0200 | [diff] [blame] | 28 | def artifactoryBirdUrl = "https://artifactory.mcp.mirantis.net/artifactory/binary-prod-local" |
| 29 | |
Sergey Kulanov | 4add50c | 2016-11-29 11:20:42 +0200 | [diff] [blame^] | 30 | def confdBuildId = config.confdBuildId ?: "${artifactoryBirdUrl}/${projectNamespace}/confd/latest".toURL().text.trim() |
| 31 | def confdUrl = config.confdUrl ?: "${artifactoryBirdUrl}/${projectNamespace}/confd/confd-${confdBuildId}" |
| 32 | |
Sergey Kulanov | 74910b6 | 2016-11-28 18:00:17 +0200 | [diff] [blame] | 33 | def birdBuildId = config.birdBuildId ?: "${artifactoryBirdUrl}/${projectNamespace}/bird/latest".toURL().text.trim() |
| 34 | def birdUrl = config.birdUrl ?: "${artifactoryBirdUrl}/${projectNamespace}/bird/bird-${birdBuildId}" |
| 35 | def bird6Url = config.bird6Url ?: "${artifactoryBirdUrl}/${projectNamespace}/bird/bird6-${birdBuildId}" |
| 36 | def birdclUrl = config.birdclUrl ?: "${artifactoryBirdUrl}/${projectNamespace}/bird/birdcl-${birdBuildId}" |
Sergey Kulanov | 247c4e7 | 2016-10-17 16:43:29 +0300 | [diff] [blame] | 37 | |
Sergey Kulanov | 00d7434 | 2016-10-24 15:22:11 +0300 | [diff] [blame] | 38 | def gitCommit = sh(returnStdout: true, script: "git rev-parse --short HEAD").trim() |
Sergey Kulanov | 247c4e7 | 2016-10-17 16:43:29 +0300 | [diff] [blame] | 39 | |
| 40 | def build = "${config.containersBuildId}-${gitCommit}" |
| 41 | |
| 42 | // return values |
Sergey Kulanov | 2202ad2 | 2016-10-18 17:14:12 +0300 | [diff] [blame] | 43 | def calicoNodeImageRepo = "${dockerRepo}/${nodeImage}" |
| 44 | def calicoCtlImageRepo = "${dockerRepo}/${ctlImage}" |
| 45 | def calicoVersion = "${nodeImageTag}-${build}" |
| 46 | def ctlContainerName = "${ctlName}-${build}" |
| 47 | def nodeContainerName = "${nodeName}-${build}" |
Sergey Kulanov | 247c4e7 | 2016-10-17 16:43:29 +0300 | [diff] [blame] | 48 | |
| 49 | // Start build section |
| 50 | |
| 51 | stage ('Build calico/ctl image'){ |
| 52 | sh """ |
Sergey Kulanov | d7ea0fe | 2016-11-05 14:00:20 +0200 | [diff] [blame] | 53 | make calico/ctl \ |
Sergey Kulanov | 2202ad2 | 2016-10-18 17:14:12 +0300 | [diff] [blame] | 54 | CTL_CONTAINER_NAME=${ctlContainerName} \ |
Sergey Kulanov | 1c15df0 | 2016-11-21 16:59:59 +0200 | [diff] [blame] | 55 | PYTHON_BUILD_CONTAINER_NAME=${buildImage} \ |
Sergey Kulanov | 247c4e7 | 2016-10-17 16:43:29 +0300 | [diff] [blame] | 56 | BIRDCL_URL=${birdclUrl} |
| 57 | """ |
| 58 | } |
| 59 | |
Sergey Kulanov | 9cef925 | 2016-11-07 11:27:50 +0000 | [diff] [blame] | 60 | |
Sergey Kulanov | 247c4e7 | 2016-10-17 16:43:29 +0300 | [diff] [blame] | 61 | stage('Build calico/node'){ |
| 62 | sh """ |
Sergey Kulanov | d7ea0fe | 2016-11-05 14:00:20 +0200 | [diff] [blame] | 63 | make calico/node \ |
Sergey Kulanov | 2202ad2 | 2016-10-18 17:14:12 +0300 | [diff] [blame] | 64 | NODE_CONTAINER_NAME=${nodeContainerName} \ |
Sergey Kulanov | 1c15df0 | 2016-11-21 16:59:59 +0200 | [diff] [blame] | 65 | PYTHON_BUILD_CONTAINER_NAME=${buildImage} \ |
Sergey Kulanov | 247c4e7 | 2016-10-17 16:43:29 +0300 | [diff] [blame] | 66 | FELIX_CONTAINER_NAME=${felixImage} \ |
| 67 | CONFD_URL=${confdUrl} \ |
| 68 | BIRD_URL=${birdUrl} \ |
| 69 | BIRD6_URL=${bird6Url} \ |
| 70 | BIRDCL_URL=${birdclUrl} |
| 71 | """ |
| 72 | } |
| 73 | |
| 74 | |
Sergey Kulanov | 2202ad2 | 2016-10-18 17:14:12 +0300 | [diff] [blame] | 75 | dir("artifacts"){ |
| 76 | // Save the last build ID |
| 77 | writeFile file: "lastbuild", text: "${build}" |
| 78 | // Create config yaml for Kargo |
| 79 | writeFile file: "calico-containers-${build}.yaml", |
| 80 | text: """\ |
| 81 | calico_node_image_repo: ${calicoNodeImageRepo} |
| 82 | calicoctl_image_repo: ${calicoCtlImageRepo} |
| 83 | calico_version: ${calicoVersion} |
| 84 | """.stripIndent() |
| 85 | } // dir artifacts |
Sergey Kulanov | 247c4e7 | 2016-10-17 16:43:29 +0300 | [diff] [blame] | 86 | |
| 87 | return [ |
Sergey Kulanov | 2202ad2 | 2016-10-18 17:14:12 +0300 | [diff] [blame] | 88 | CTL_CONTAINER_NAME:"${ctlContainerName}", |
| 89 | NODE_CONTAINER_NAME:"${nodeContainerName}", |
Sergey Kulanov | 247c4e7 | 2016-10-17 16:43:29 +0300 | [diff] [blame] | 90 | CALICO_NODE_IMAGE_REPO:"${calicoNodeImageRepo}", |
| 91 | CALICOCTL_IMAGE_REPO:"${calicoCtlImageRepo}", |
| 92 | CALICO_VERSION: "${calicoVersion}" |
| 93 | ] |
| 94 | |
| 95 | } |