blob: fc7bd6f42b23f2ccb9ebfeabab353292d6b93e6a [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
37 def buildImage = config.buildImage ?: "${artifactoryUrl}/mcp/libcalico/lastbuild".toURL().text.trim()
38 def felixImage = config.felixImage ?: "${artifactoryUrl}/mcp/felix/lastbuild".toURL().text.trim()
39
40 def confdBuildId = config.confdBuildId ?: "${artifactoryUrl}/mcp/confd/lastbuild".toURL().text.trim()
41 def confdUrl = config.confdUrl ?: "${artifactoryUrl}/mcp/confd/confd-${confdBuildId}"
42
43 def birdBuildId = config.birdBuildId ?: "${artifactoryUrl}/mcp/calico-bird/lastbuild".toURL().text.trim()
44 def birdUrl = config.birdUrl ?: "${artifactoryUrl}/mcp/calico-bird/bird-${birdBuildId}"
45 def bird6Url = config.bird6Url ?: "${artifactoryUrl}/mcp/calico-bird/bird6-${birdBuildId}"
46 def birdclUrl = config.birdclUrl ?: "${artifactoryUrl}/mcp/calico-bird/birdcl-${birdBuildId}"
47
48 // add LABELs to dockerfiles
49 def docker = new com.mirantis.mcp.Docker()
50 docker.setDockerfileLabels("./calicoctl/Dockerfile.calicoctl",
51 ["docker.imgTag=${imgTag}",
52 "calico.buildImage=${buildImage}",
53 "calico.birdclUrl=${birdclUrl}"])
54
55 docker.setDockerfileLabels("./calico_node/Dockerfile",
56 ["docker.imgTag=${imgTag}",
57 "calico.buildImage=${buildImage}",
58 "calico.felixImage=${felixImage}",
59 "calico.confdUrl=${confdUrl}",
60 "calico.birdUrl=${birdUrl}",
61 "calico.bird6Url=${bird6Url}",
62 "calico.birdclUrl=${birdclUrl}"])
63
64 // Start build section
65 stage ('Build calico/ctl image'){
66 sh """
67 make calico/ctl \
68 CTL_CONTAINER_NAME=${ctlName} \
69 PYTHON_BUILD_CONTAINER_NAME=${buildImage} \
70 BIRDCL_URL=${birdclUrl}
71 """
72 }
73
74
75 stage('Build calico/node'){
76 sh """
77 make calico/node \
78 NODE_CONTAINER_NAME=${nodeName} \
79 PYTHON_BUILD_CONTAINER_NAME=${buildImage} \
80 FELIX_CONTAINER_NAME=${felixImage} \
81 CONFD_URL=${confdUrl} \
82 BIRD_URL=${birdUrl} \
83 BIRD6_URL=${bird6Url} \
84 BIRDCL_URL=${birdclUrl}
85 """
86 }
87
88
89 return [
90 CTL_CONTAINER_NAME:"${ctlName}",
91 NODE_CONTAINER_NAME:"${nodeName}",
Sergey Kulanov1f308612016-11-28 16:50:22 +020092 CALICO_NODE_IMAGE_REPO:"${nodeImage}",
93 CALICOCTL_IMAGE_REPO:"${ctlImage}",
Sergey Kulanovfaae3862016-11-28 13:27:36 +020094 CALICO_VERSION: "${imgTag}"
95 ]
96
97}