blob: d9dd45f949ad7c3bdd6078d68c04ce965ae59b49 [file] [log] [blame]
Sergey Kulanov247c4e72016-10-17 16:43:29 +03001def 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 Kulanov247c4e72016-10-17 16:43:29 +03008
Sergey Kulanov3f117e82016-11-30 17:41:23 +02009 def dockerRepo = config.dockerRepo ?: "artifactory.mcp.mirantis.net:5008"
Sergey Kulanov93fa5162016-11-29 13:28:06 +020010 def projectNamespace = "mirantis/projectcalico"
11 def artifactoryUrl = config.artifactoryURL ?: "https://artifactory.mcp.mirantis.net/artifactory/binary-prod-virtual"
Sergey Kulanov247c4e72016-10-17 16:43:29 +030012
Sergey Kulanov93fa5162016-11-29 13:28:06 +020013 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 Kulanov247c4e72016-10-17 16:43:29 +030016
Sergey Kulanov93fa5162016-11-29 13:28:06 +020017 def nodeImage = config.nodeImage ?: "${dockerRepo}/${projectNamespace}/calico/node"
18 def nodeName = "${nodeImage}:${imgTag}"
Sergey Kulanov247c4e72016-10-17 16:43:29 +030019
Sergey Kulanov93fa5162016-11-29 13:28:06 +020020 def ctlImage = config.ctlImage ?: "${dockerRepo}/${projectNamespace}/calico/ctl"
21 def ctlName = "${ctlImage}:${imgTag}"
Sergey Kulanov247c4e72016-10-17 16:43:29 +030022
Sergey Kulanov93fa5162016-11-29 13:28:06 +020023 // 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 Kulanov74910b62016-11-28 18:00:17 +020027
Sergey Kulanov93fa5162016-11-29 13:28:06 +020028 def confdBuildId = config.confdBuildId ?: "${artifactoryUrl}/${projectNamespace}/confd/latest".toURL().text.trim()
29 def confdUrl = config.confdUrl ?: "${artifactoryUrl}/${projectNamespace}/confd/confd-${confdBuildId}"
Sergey Kulanov4add50c2016-11-29 11:20:42 +020030
Sergey Kulanov93fa5162016-11-29 13:28:06 +020031 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 Kulanov247c4e72016-10-17 16:43:29 +030035
Sergey Kulanov93fa5162016-11-29 13:28:06 +020036 // 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 Kulanov247c4e72016-10-17 16:43:29 +030042
Sergey Kulanov93fa5162016-11-29 13:28:06 +020043 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 Kulanov247c4e72016-10-17 16:43:29 +030051
52 // Start build section
Sergey Kulanov247c4e72016-10-17 16:43:29 +030053 stage ('Build calico/ctl image'){
54 sh """
Sergey Kulanovd7ea0fe2016-11-05 14:00:20 +020055 make calico/ctl \
Sergey Kulanov93fa5162016-11-29 13:28:06 +020056 CTL_CONTAINER_NAME=${ctlName} \
Sergey Kulanov1c15df02016-11-21 16:59:59 +020057 PYTHON_BUILD_CONTAINER_NAME=${buildImage} \
Sergey Kulanov247c4e72016-10-17 16:43:29 +030058 BIRDCL_URL=${birdclUrl}
59 """
60 }
61
Sergey Kulanov9cef9252016-11-07 11:27:50 +000062
Sergey Kulanov247c4e72016-10-17 16:43:29 +030063 stage('Build calico/node'){
64 sh """
Sergey Kulanovd7ea0fe2016-11-05 14:00:20 +020065 make calico/node \
Sergey Kulanov93fa5162016-11-29 13:28:06 +020066 NODE_CONTAINER_NAME=${nodeName} \
Sergey Kulanov1c15df02016-11-21 16:59:59 +020067 PYTHON_BUILD_CONTAINER_NAME=${buildImage} \
Sergey Kulanov247c4e72016-10-17 16:43:29 +030068 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 Kulanov247c4e72016-10-17 16:43:29 +030077 return [
Sergey Kulanov93fa5162016-11-29 13:28:06 +020078 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 Kulanov247c4e72016-10-17 16:43:29 +030083 ]
84
85}