blob: 1613120e334f0ba986e7c9475f038cbe379f9250 [file] [log] [blame]
Denis Egorenkoff32a4d2016-12-21 14:41:53 +00001def 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
9 def dockerRepo = config.dockerRepo
10 def projectNamespace = "mirantis/projectcalico"
11 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 }
20
21 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()
24
25 def nodeImage = config.nodeImage ?: "${dockerRepo}/${projectNamespace}/calico/node"
26 def nodeName = "${nodeImage}:${imgTag}"
27
28 def ctlImage = config.ctlImage ?: "${dockerRepo}/${projectNamespace}/calico/ctl"
29 def ctlName = "${ctlImage}:${imgTag}"
30
31 // 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"
35
36 def confdBuildId = config.confdBuildId ?: "${artifactoryUrl}/${projectNamespace}/confd/latest".toURL().text.trim()
37 def confdUrl = config.confdUrl ?: "${artifactoryUrl}/${projectNamespace}/confd/confd-${confdBuildId}"
38
39 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}"
43
44 // 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}"])
50
51 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}"])
59
60 // Start build section
61 stage ('Build calico/ctl image'){
62 sh """
63 make calico/ctl \
64 CTL_CONTAINER_NAME=${ctlName} \
65 PYTHON_BUILD_CONTAINER_NAME=${buildImage} \
66 BIRDCL_URL=${birdclUrl}
67 """
68 }
69
70
71 stage('Build calico/node'){
72 sh """
73 make calico/node \
74 NODE_CONTAINER_NAME=${nodeName} \
75 PYTHON_BUILD_CONTAINER_NAME=${buildImage} \
76 FELIX_CONTAINER_NAME=${felixImage} \
77 CONFD_URL=${confdUrl} \
78 BIRD_URL=${birdUrl} \
79 BIRD6_URL=${bird6Url} \
80 BIRDCL_URL=${birdclUrl}
81 """
82 }
83
84
85 return [
86 CTL_CONTAINER_NAME:"${ctlName}",
87 NODE_CONTAINER_NAME:"${nodeName}",
88 CALICO_NODE_IMAGE_REPO:"${nodeImage}",
89 CALICOCTL_IMAGE_REPO:"${ctlImage}",
90 CALICO_VERSION: "${imgTag}"
91 ]
92
93}