blob: 1613120e334f0ba986e7c9475f038cbe379f9250 [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
Denis Egorenko33043c12016-12-07 13:34:59 +04009 def dockerRepo = config.dockerRepo
Sergey Kulanov93fa5162016-11-29 13:28:06 +020010 def projectNamespace = "mirantis/projectcalico"
Denis Egorenko33043c12016-12-07 13:34:59 +040011 def artifactoryUrl = config.artifactoryURL
12
13 if (! dockerRepo ) {
14 error('dockerRepo parameter have to be set.')
15 }
16
17 if (! artifactoryUrl ) {
18 error('artifactoryUrl parameter have to be set.')
19 }
Sergey Kulanov247c4e72016-10-17 16:43:29 +030020
Sergey Kulanov93fa5162016-11-29 13:28:06 +020021 def git = new com.mirantis.mcp.Git()
22 def common = new com.mirantis.mcp.Common()
23 def imgTag = config.imageTag ?: git.getGitDescribe(true) + "-" + common.getDatetime()
Sergey Kulanov247c4e72016-10-17 16:43:29 +030024
Sergey Kulanov93fa5162016-11-29 13:28:06 +020025 def nodeImage = config.nodeImage ?: "${dockerRepo}/${projectNamespace}/calico/node"
26 def nodeName = "${nodeImage}:${imgTag}"
Sergey Kulanov247c4e72016-10-17 16:43:29 +030027
Sergey Kulanov93fa5162016-11-29 13:28:06 +020028 def ctlImage = config.ctlImage ?: "${dockerRepo}/${projectNamespace}/calico/ctl"
29 def ctlName = "${ctlImage}:${imgTag}"
Sergey Kulanov247c4e72016-10-17 16:43:29 +030030
Sergey Kulanov93fa5162016-11-29 13:28:06 +020031 // calico/build goes from libcalico
32 def buildImage = config.buildImage ?: "${dockerRepo}/${projectNamespace}/calico/build:latest"
33 // calico/felix goes from felix
34 def felixImage = config.felixImage ?: "${dockerRepo}/${projectNamespace}/calico/felix:latest"
Sergey Kulanov74910b62016-11-28 18:00:17 +020035
Sergey Kulanov93fa5162016-11-29 13:28:06 +020036 def confdBuildId = config.confdBuildId ?: "${artifactoryUrl}/${projectNamespace}/confd/latest".toURL().text.trim()
37 def confdUrl = config.confdUrl ?: "${artifactoryUrl}/${projectNamespace}/confd/confd-${confdBuildId}"
Sergey Kulanov4add50c2016-11-29 11:20:42 +020038
Sergey Kulanov93fa5162016-11-29 13:28:06 +020039 def birdBuildId = config.birdBuildId ?: "${artifactoryUrl}/${projectNamespace}/bird/latest".toURL().text.trim()
40 def birdUrl = config.birdUrl ?: "${artifactoryUrl}/${projectNamespace}/bird/bird-${birdBuildId}"
41 def bird6Url = config.bird6Url ?: "${artifactoryUrl}/${projectNamespace}/bird/bird6-${birdBuildId}"
42 def birdclUrl = config.birdclUrl ?: "${artifactoryUrl}/${projectNamespace}/bird/birdcl-${birdBuildId}"
Sergey Kulanov247c4e72016-10-17 16:43:29 +030043
Sergey Kulanov93fa5162016-11-29 13:28:06 +020044 // add LABELs to dockerfiles
45 def docker = new com.mirantis.mcp.Docker()
46 docker.setDockerfileLabels("./calicoctl/Dockerfile.calicoctl",
47 ["docker.imgTag=${imgTag}",
48 "calico.buildImage=${buildImage}",
49 "calico.birdclUrl=${birdclUrl}"])
Sergey Kulanov247c4e72016-10-17 16:43:29 +030050
Sergey Kulanov93fa5162016-11-29 13:28:06 +020051 docker.setDockerfileLabels("./calico_node/Dockerfile",
52 ["docker.imgTag=${imgTag}",
53 "calico.buildImage=${buildImage}",
54 "calico.felixImage=${felixImage}",
55 "calico.confdUrl=${confdUrl}",
56 "calico.birdUrl=${birdUrl}",
57 "calico.bird6Url=${bird6Url}",
58 "calico.birdclUrl=${birdclUrl}"])
Sergey Kulanov247c4e72016-10-17 16:43:29 +030059
60 // Start build section
Sergey Kulanov247c4e72016-10-17 16:43:29 +030061 stage ('Build calico/ctl image'){
62 sh """
Sergey Kulanovd7ea0fe2016-11-05 14:00:20 +020063 make calico/ctl \
Sergey Kulanov93fa5162016-11-29 13:28:06 +020064 CTL_CONTAINER_NAME=${ctlName} \
Sergey Kulanov1c15df02016-11-21 16:59:59 +020065 PYTHON_BUILD_CONTAINER_NAME=${buildImage} \
Sergey Kulanov247c4e72016-10-17 16:43:29 +030066 BIRDCL_URL=${birdclUrl}
67 """
68 }
69
Sergey Kulanov9cef9252016-11-07 11:27:50 +000070
Sergey Kulanov247c4e72016-10-17 16:43:29 +030071 stage('Build calico/node'){
72 sh """
Sergey Kulanovd7ea0fe2016-11-05 14:00:20 +020073 make calico/node \
Sergey Kulanov93fa5162016-11-29 13:28:06 +020074 NODE_CONTAINER_NAME=${nodeName} \
Sergey Kulanov1c15df02016-11-21 16:59:59 +020075 PYTHON_BUILD_CONTAINER_NAME=${buildImage} \
Sergey Kulanov247c4e72016-10-17 16:43:29 +030076 FELIX_CONTAINER_NAME=${felixImage} \
77 CONFD_URL=${confdUrl} \
78 BIRD_URL=${birdUrl} \
79 BIRD6_URL=${bird6Url} \
80 BIRDCL_URL=${birdclUrl}
81 """
82 }
83
84
Sergey Kulanov247c4e72016-10-17 16:43:29 +030085 return [
Sergey Kulanov93fa5162016-11-29 13:28:06 +020086 CTL_CONTAINER_NAME:"${ctlName}",
87 NODE_CONTAINER_NAME:"${nodeName}",
88 CALICO_NODE_IMAGE_REPO:"${nodeImage}",
89 CALICOCTL_IMAGE_REPO:"${ctlImage}",
90 CALICO_VERSION: "${imgTag}"
Sergey Kulanov247c4e72016-10-17 16:43:29 +030091 ]
92
93}