blob: e77d236602583356ab607d1e07a2d53be8e4a2e6 [file] [log] [blame]
Sergey Kulanovfaae3862016-11-28 13:27:36 +02001def 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 Kulanov6d9a4f82016-11-28 16:37:27 +02009 def dockerRepo = config.dockerRepo ?: "artifactory.mcp.mirantis.net:5007"
Sergey Kulanovfaae3862016-11-28 13:27:36 +020010 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 Kulanovfedaf302016-11-29 12:29:47 +020037 def buildImage = config.buildImage ?: "${dockerRepo}/mirantis/projectcalico/calico/build:latest"
Sergey Kulanovfaae3862016-11-28 13:27:36 +020038 def felixImage = config.felixImage ?: "${artifactoryUrl}/mcp/felix/lastbuild".toURL().text.trim()
39
Sergey Kulanov74910b62016-11-28 18:00:17 +020040 def artifactoryBirdUrl = "https://artifactory.mcp.mirantis.net/artifactory/binary-prod-local"
41
Sergey Kulanov4add50c2016-11-29 11:20:42 +020042 def confdBuildId = config.confdBuildId ?: "${artifactoryBirdUrl}/${projectNamespace}/confd/latest".toURL().text.trim()
43 def confdUrl = config.confdUrl ?: "${artifactoryBirdUrl}/${projectNamespace}/confd/confd-${confdBuildId}"
44
Sergey Kulanov74910b62016-11-28 18:00:17 +020045 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 Kulanovfaae3862016-11-28 13:27:36 +020049
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 Kulanov1f308612016-11-28 16:50:22 +020094 CALICO_NODE_IMAGE_REPO:"${nodeImage}",
95 CALICOCTL_IMAGE_REPO:"${ctlImage}",
Sergey Kulanovfaae3862016-11-28 13:27:36 +020096 CALICO_VERSION: "${imgTag}"
97 ]
98
99}