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 | 3f117e8 | 2016-11-30 17:41:23 +0200 | [diff] [blame^] | 9 | def dockerRepo = config.dockerRepo ?: "artifactory.mcp.mirantis.net:5008" |
Sergey Kulanov | 93fa516 | 2016-11-29 13:28:06 +0200 | [diff] [blame] | 10 | def projectNamespace = "mirantis/projectcalico" |
| 11 | def artifactoryUrl = config.artifactoryURL ?: "https://artifactory.mcp.mirantis.net/artifactory/binary-prod-virtual" |
Sergey Kulanov | 247c4e7 | 2016-10-17 16:43:29 +0300 | [diff] [blame] | 12 | |
Sergey Kulanov | 93fa516 | 2016-11-29 13:28:06 +0200 | [diff] [blame] | 13 | def git = new com.mirantis.mcp.Git() |
| 14 | def common = new com.mirantis.mcp.Common() |
| 15 | def imgTag = config.imageTag ?: git.getGitDescribe(true) + "-" + common.getDatetime() |
Sergey Kulanov | 247c4e7 | 2016-10-17 16:43:29 +0300 | [diff] [blame] | 16 | |
Sergey Kulanov | 93fa516 | 2016-11-29 13:28:06 +0200 | [diff] [blame] | 17 | def nodeImage = config.nodeImage ?: "${dockerRepo}/${projectNamespace}/calico/node" |
| 18 | def nodeName = "${nodeImage}:${imgTag}" |
Sergey Kulanov | 247c4e7 | 2016-10-17 16:43:29 +0300 | [diff] [blame] | 19 | |
Sergey Kulanov | 93fa516 | 2016-11-29 13:28:06 +0200 | [diff] [blame] | 20 | def ctlImage = config.ctlImage ?: "${dockerRepo}/${projectNamespace}/calico/ctl" |
| 21 | def ctlName = "${ctlImage}:${imgTag}" |
Sergey Kulanov | 247c4e7 | 2016-10-17 16:43:29 +0300 | [diff] [blame] | 22 | |
Sergey Kulanov | 93fa516 | 2016-11-29 13:28:06 +0200 | [diff] [blame] | 23 | // calico/build goes from libcalico |
| 24 | def buildImage = config.buildImage ?: "${dockerRepo}/${projectNamespace}/calico/build:latest" |
| 25 | // calico/felix goes from felix |
| 26 | def felixImage = config.felixImage ?: "${dockerRepo}/${projectNamespace}/calico/felix:latest" |
Sergey Kulanov | 74910b6 | 2016-11-28 18:00:17 +0200 | [diff] [blame] | 27 | |
Sergey Kulanov | 93fa516 | 2016-11-29 13:28:06 +0200 | [diff] [blame] | 28 | def confdBuildId = config.confdBuildId ?: "${artifactoryUrl}/${projectNamespace}/confd/latest".toURL().text.trim() |
| 29 | def confdUrl = config.confdUrl ?: "${artifactoryUrl}/${projectNamespace}/confd/confd-${confdBuildId}" |
Sergey Kulanov | 4add50c | 2016-11-29 11:20:42 +0200 | [diff] [blame] | 30 | |
Sergey Kulanov | 93fa516 | 2016-11-29 13:28:06 +0200 | [diff] [blame] | 31 | def birdBuildId = config.birdBuildId ?: "${artifactoryUrl}/${projectNamespace}/bird/latest".toURL().text.trim() |
| 32 | def birdUrl = config.birdUrl ?: "${artifactoryUrl}/${projectNamespace}/bird/bird-${birdBuildId}" |
| 33 | def bird6Url = config.bird6Url ?: "${artifactoryUrl}/${projectNamespace}/bird/bird6-${birdBuildId}" |
| 34 | def birdclUrl = config.birdclUrl ?: "${artifactoryUrl}/${projectNamespace}/bird/birdcl-${birdBuildId}" |
Sergey Kulanov | 247c4e7 | 2016-10-17 16:43:29 +0300 | [diff] [blame] | 35 | |
Sergey Kulanov | 93fa516 | 2016-11-29 13:28:06 +0200 | [diff] [blame] | 36 | // add LABELs to dockerfiles |
| 37 | def docker = new com.mirantis.mcp.Docker() |
| 38 | docker.setDockerfileLabels("./calicoctl/Dockerfile.calicoctl", |
| 39 | ["docker.imgTag=${imgTag}", |
| 40 | "calico.buildImage=${buildImage}", |
| 41 | "calico.birdclUrl=${birdclUrl}"]) |
Sergey Kulanov | 247c4e7 | 2016-10-17 16:43:29 +0300 | [diff] [blame] | 42 | |
Sergey Kulanov | 93fa516 | 2016-11-29 13:28:06 +0200 | [diff] [blame] | 43 | docker.setDockerfileLabels("./calico_node/Dockerfile", |
| 44 | ["docker.imgTag=${imgTag}", |
| 45 | "calico.buildImage=${buildImage}", |
| 46 | "calico.felixImage=${felixImage}", |
| 47 | "calico.confdUrl=${confdUrl}", |
| 48 | "calico.birdUrl=${birdUrl}", |
| 49 | "calico.bird6Url=${bird6Url}", |
| 50 | "calico.birdclUrl=${birdclUrl}"]) |
Sergey Kulanov | 247c4e7 | 2016-10-17 16:43:29 +0300 | [diff] [blame] | 51 | |
| 52 | // Start build section |
Sergey Kulanov | 247c4e7 | 2016-10-17 16:43:29 +0300 | [diff] [blame] | 53 | stage ('Build calico/ctl image'){ |
| 54 | sh """ |
Sergey Kulanov | d7ea0fe | 2016-11-05 14:00:20 +0200 | [diff] [blame] | 55 | make calico/ctl \ |
Sergey Kulanov | 93fa516 | 2016-11-29 13:28:06 +0200 | [diff] [blame] | 56 | CTL_CONTAINER_NAME=${ctlName} \ |
Sergey Kulanov | 1c15df0 | 2016-11-21 16:59:59 +0200 | [diff] [blame] | 57 | PYTHON_BUILD_CONTAINER_NAME=${buildImage} \ |
Sergey Kulanov | 247c4e7 | 2016-10-17 16:43:29 +0300 | [diff] [blame] | 58 | BIRDCL_URL=${birdclUrl} |
| 59 | """ |
| 60 | } |
| 61 | |
Sergey Kulanov | 9cef925 | 2016-11-07 11:27:50 +0000 | [diff] [blame] | 62 | |
Sergey Kulanov | 247c4e7 | 2016-10-17 16:43:29 +0300 | [diff] [blame] | 63 | stage('Build calico/node'){ |
| 64 | sh """ |
Sergey Kulanov | d7ea0fe | 2016-11-05 14:00:20 +0200 | [diff] [blame] | 65 | make calico/node \ |
Sergey Kulanov | 93fa516 | 2016-11-29 13:28:06 +0200 | [diff] [blame] | 66 | NODE_CONTAINER_NAME=${nodeName} \ |
Sergey Kulanov | 1c15df0 | 2016-11-21 16:59:59 +0200 | [diff] [blame] | 67 | PYTHON_BUILD_CONTAINER_NAME=${buildImage} \ |
Sergey Kulanov | 247c4e7 | 2016-10-17 16:43:29 +0300 | [diff] [blame] | 68 | FELIX_CONTAINER_NAME=${felixImage} \ |
| 69 | CONFD_URL=${confdUrl} \ |
| 70 | BIRD_URL=${birdUrl} \ |
| 71 | BIRD6_URL=${bird6Url} \ |
| 72 | BIRDCL_URL=${birdclUrl} |
| 73 | """ |
| 74 | } |
| 75 | |
| 76 | |
Sergey Kulanov | 247c4e7 | 2016-10-17 16:43:29 +0300 | [diff] [blame] | 77 | return [ |
Sergey Kulanov | 93fa516 | 2016-11-29 13:28:06 +0200 | [diff] [blame] | 78 | CTL_CONTAINER_NAME:"${ctlName}", |
| 79 | NODE_CONTAINER_NAME:"${nodeName}", |
| 80 | CALICO_NODE_IMAGE_REPO:"${nodeImage}", |
| 81 | CALICOCTL_IMAGE_REPO:"${ctlImage}", |
| 82 | CALICO_VERSION: "${imgTag}" |
Sergey Kulanov | 247c4e7 | 2016-10-17 16:43:29 +0300 | [diff] [blame] | 83 | ] |
| 84 | |
| 85 | } |