Sergey Kulanov | faae386 | 2016-11-28 13:27:36 +0200 | [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 | |
| 8 | |
Sergey Kulanov | 6d9a4f8 | 2016-11-28 16:37:27 +0200 | [diff] [blame] | 9 | def dockerRepo = config.dockerRepo ?: "artifactory.mcp.mirantis.net:5007" |
Sergey Kulanov | faae386 | 2016-11-28 13:27:36 +0200 | [diff] [blame] | 10 | def projectNamespace = "mirantis/projectcalico" |
| 11 | |
| 12 | def git = new com.mirantis.mcp.Git() |
| 13 | def common = new com.mirantis.mcp.Common() |
| 14 | def imgTag = config.imageTag ?: git.getGitDescribe(true) + "-" + common.getDatetime() |
| 15 | |
| 16 | def nodeImage = config.nodeImage ?: "${dockerRepo}/${projectNamespace}/calico/node" |
| 17 | def nodeName = "${nodeImage}:${imgTag}" |
| 18 | |
| 19 | def ctlImage = config.ctlImage ?: "${dockerRepo}/${projectNamespace}/calico/ctl" |
| 20 | def ctlName = "${ctlImage}:${imgTag}" |
| 21 | |
| 22 | // FIXME(skulanov): new schema should be used after binary promotion |
| 23 | // // calico/build goes from libcalico |
| 24 | // def buildImage = config.buildImage ?: "${dockerRepo}/mirantis/projectcalico/calico/build:latest" |
| 25 | // calico/felix felix |
| 26 | // def felixImage = config.felixImage ?: "${dockerRepo}/mirantis/projectcalico/calico/felix:latest" |
| 27 | // def artifactoryUrl = config.artifactoryURL ?: "https://artifactory.mcp.mirantis.net/artifactory/binary-prod-virtual" |
| 28 | // def confdBuildId = config.confdBuildId ?: "${artifactoryUrl}/${projectNamespace}/confd/latest".toURL().text.trim() |
| 29 | // def confdUrl = config.confdUrl ?: "${artifactoryUrl}/${projectNamespace}/confd/confd-${confdBuildId}" |
| 30 | |
| 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}" |
| 35 | def artifactoryUrl = config.artifactoryURL ?: "https://artifactory.mcp.mirantis.net/artifactory/projectcalico" |
| 36 | |
Sergey Kulanov | fedaf30 | 2016-11-29 12:29:47 +0200 | [diff] [blame^] | 37 | def buildImage = config.buildImage ?: "${dockerRepo}/mirantis/projectcalico/calico/build:latest" |
Sergey Kulanov | faae386 | 2016-11-28 13:27:36 +0200 | [diff] [blame] | 38 | def felixImage = config.felixImage ?: "${artifactoryUrl}/mcp/felix/lastbuild".toURL().text.trim() |
| 39 | |
Sergey Kulanov | 74910b6 | 2016-11-28 18:00:17 +0200 | [diff] [blame] | 40 | def artifactoryBirdUrl = "https://artifactory.mcp.mirantis.net/artifactory/binary-prod-local" |
| 41 | |
Sergey Kulanov | 4add50c | 2016-11-29 11:20:42 +0200 | [diff] [blame] | 42 | def confdBuildId = config.confdBuildId ?: "${artifactoryBirdUrl}/${projectNamespace}/confd/latest".toURL().text.trim() |
| 43 | def confdUrl = config.confdUrl ?: "${artifactoryBirdUrl}/${projectNamespace}/confd/confd-${confdBuildId}" |
| 44 | |
Sergey Kulanov | 74910b6 | 2016-11-28 18:00:17 +0200 | [diff] [blame] | 45 | def birdBuildId = config.birdBuildId ?: "${artifactoryBirdUrl}/${projectNamespace}/bird/latest".toURL().text.trim() |
| 46 | def birdUrl = config.birdUrl ?: "${artifactoryBirdUrl}/${projectNamespace}/bird/bird-${birdBuildId}" |
| 47 | def bird6Url = config.bird6Url ?: "${artifactoryBirdUrl}/${projectNamespace}/bird/bird6-${birdBuildId}" |
| 48 | def birdclUrl = config.birdclUrl ?: "${artifactoryBirdUrl}/${projectNamespace}/bird/birdcl-${birdBuildId}" |
Sergey Kulanov | faae386 | 2016-11-28 13:27:36 +0200 | [diff] [blame] | 49 | |
| 50 | // add LABELs to dockerfiles |
| 51 | def docker = new com.mirantis.mcp.Docker() |
| 52 | docker.setDockerfileLabels("./calicoctl/Dockerfile.calicoctl", |
| 53 | ["docker.imgTag=${imgTag}", |
| 54 | "calico.buildImage=${buildImage}", |
| 55 | "calico.birdclUrl=${birdclUrl}"]) |
| 56 | |
| 57 | docker.setDockerfileLabels("./calico_node/Dockerfile", |
| 58 | ["docker.imgTag=${imgTag}", |
| 59 | "calico.buildImage=${buildImage}", |
| 60 | "calico.felixImage=${felixImage}", |
| 61 | "calico.confdUrl=${confdUrl}", |
| 62 | "calico.birdUrl=${birdUrl}", |
| 63 | "calico.bird6Url=${bird6Url}", |
| 64 | "calico.birdclUrl=${birdclUrl}"]) |
| 65 | |
| 66 | // Start build section |
| 67 | stage ('Build calico/ctl image'){ |
| 68 | sh """ |
| 69 | make calico/ctl \ |
| 70 | CTL_CONTAINER_NAME=${ctlName} \ |
| 71 | PYTHON_BUILD_CONTAINER_NAME=${buildImage} \ |
| 72 | BIRDCL_URL=${birdclUrl} |
| 73 | """ |
| 74 | } |
| 75 | |
| 76 | |
| 77 | stage('Build calico/node'){ |
| 78 | sh """ |
| 79 | make calico/node \ |
| 80 | NODE_CONTAINER_NAME=${nodeName} \ |
| 81 | PYTHON_BUILD_CONTAINER_NAME=${buildImage} \ |
| 82 | FELIX_CONTAINER_NAME=${felixImage} \ |
| 83 | CONFD_URL=${confdUrl} \ |
| 84 | BIRD_URL=${birdUrl} \ |
| 85 | BIRD6_URL=${bird6Url} \ |
| 86 | BIRDCL_URL=${birdclUrl} |
| 87 | """ |
| 88 | } |
| 89 | |
| 90 | |
| 91 | return [ |
| 92 | CTL_CONTAINER_NAME:"${ctlName}", |
| 93 | NODE_CONTAINER_NAME:"${nodeName}", |
Sergey Kulanov | 1f30861 | 2016-11-28 16:50:22 +0200 | [diff] [blame] | 94 | CALICO_NODE_IMAGE_REPO:"${nodeImage}", |
| 95 | CALICOCTL_IMAGE_REPO:"${ctlImage}", |
Sergey Kulanov | faae386 | 2016-11-28 13:27:36 +0200 | [diff] [blame] | 96 | CALICO_VERSION: "${imgTag}" |
| 97 | ] |
| 98 | |
| 99 | } |