blob: db1f1c1b313f59f79bbc9d7129a6247de059f758 [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
9 def dockerRepo = config.dockerRepo ?: "artifactory.mcp.mirantis.net:5001"
Sergey Kulanov2202ad22016-10-18 17:14:12 +030010 def artifactoryUrl = config.artifactoryURL ?: "https://artifactory.mcp.mirantis.net/artifactory/projectcalico"
Sergey Kulanov247c4e72016-10-17 16:43:29 +030011
12 def nodeImage = config.nodeImage ?: "calico/node"
13 def nodeImageTag = config.nodeImageTag ?: "v0.20.0"
14 def nodeName = "${dockerRepo}/${nodeImage}:${nodeImageTag}"
15
16 def ctlImage = config.ctlImage ?: "calico/ctl"
17 def ctlImageTag = config.ctlImageTag ?: "v0.20.0"
18 def ctlName = "${dockerRepo}/${ctlImage}:${ctlImageTag}"
19
Sergey Kulanov2202ad22016-10-18 17:14:12 +030020 // calico/build goes from {artifactoryUrl}/mcp/libcalico/
21 def buildImage = config.buildImage ?: "${artifactoryUrl}/mcp/libcalico/lastbuild".toURL().text.trim()
22 // calico/felix goes from {artifactoryUrl}/mcp/felix/
23 def felixImage = config.felixImage ?: "${artifactoryUrl}/mcp/felix/lastbuild".toURL().text.trim()
Sergey Kulanov247c4e72016-10-17 16:43:29 +030024
Sergey Kulanov2202ad22016-10-18 17:14:12 +030025 def confdBuildId = config.confdBuildId ?: "${artifactoryUrl}/mcp/confd/lastbuild".toURL().text.trim()
26 def confdUrl = config.confdUrl ?: "${artifactoryUrl}/mcp/confd/confd-${confdBuildId}"
Sergey Kulanov247c4e72016-10-17 16:43:29 +030027
Sergey Kulanov2202ad22016-10-18 17:14:12 +030028 def birdBuildId = config.birdBuildId ?: "${artifactoryUrl}/mcp/calico-bird/lastbuild".toURL().text.trim()
29 def birdUrl = config.birdUrl ?: "${artifactoryUrl}/mcp/calico-bird/bird-${birdBuildId}"
30 def bird6Url = config.bird6Url ?: "${artifactoryUrl}/mcp/calico-bird/bird6-${birdBuildId}"
31 def birdclUrl = config.birdclUrl ?: "${artifactoryUrl}/mcp/calico-bird/birdcl-${birdBuildId}"
Sergey Kulanov247c4e72016-10-17 16:43:29 +030032
Sergey Kulanov00d74342016-10-24 15:22:11 +030033 def gitCommit = sh(returnStdout: true, script: "git rev-parse --short HEAD").trim()
Sergey Kulanov247c4e72016-10-17 16:43:29 +030034
35 def build = "${config.containersBuildId}-${gitCommit}"
36
37 // return values
Sergey Kulanov2202ad22016-10-18 17:14:12 +030038 def calicoNodeImageRepo = "${dockerRepo}/${nodeImage}"
39 def calicoCtlImageRepo = "${dockerRepo}/${ctlImage}"
40 def calicoVersion = "${nodeImageTag}-${build}"
41 def ctlContainerName = "${ctlName}-${build}"
42 def nodeContainerName = "${nodeName}-${build}"
Sergey Kulanov247c4e72016-10-17 16:43:29 +030043
44 // Start build section
45
46 stage ('Build calico/ctl image'){
47 sh """
Sergey Kulanovd7ea0fe2016-11-05 14:00:20 +020048 make calico/ctl \
Sergey Kulanov2202ad22016-10-18 17:14:12 +030049 CTL_CONTAINER_NAME=${ctlContainerName} \
Sergey Kulanov247c4e72016-10-17 16:43:29 +030050 BUILD_CONTAINER_NAME=${buildImage} \
51 BIRDCL_URL=${birdclUrl}
52 """
53 }
54
Sergey Kulanov00a84f62016-10-31 14:36:18 +020055 // libcalico project should be already checkouted to
56 // calico_node/node_share/libcalico
Sergey Kulanov247c4e72016-10-17 16:43:29 +030057 stage('Build calico/node'){
58 sh """
Sergey Kulanovd7ea0fe2016-11-05 14:00:20 +020059 make calico/node \
Sergey Kulanov2202ad22016-10-18 17:14:12 +030060 NODE_CONTAINER_NAME=${nodeContainerName} \
Sergey Kulanov00a84f62016-10-31 14:36:18 +020061 NODE_CONTAINER_BUILD_ARGS='\
62 --build-arg LIBCALICO_REPO=file:///tmp/node_share/libcalico \
63 --build-arg LIBCALICO_VER=mcp' \
Sergey Kulanov247c4e72016-10-17 16:43:29 +030064 BUILD_CONTAINER_NAME=${buildImage} \
65 FELIX_CONTAINER_NAME=${felixImage} \
66 CONFD_URL=${confdUrl} \
67 BIRD_URL=${birdUrl} \
68 BIRD6_URL=${bird6Url} \
69 BIRDCL_URL=${birdclUrl}
70 """
71 }
72
73
Sergey Kulanov2202ad22016-10-18 17:14:12 +030074 dir("artifacts"){
75 // Save the last build ID
76 writeFile file: "lastbuild", text: "${build}"
77 // Create config yaml for Kargo
78 writeFile file: "calico-containers-${build}.yaml",
79 text: """\
80 calico_node_image_repo: ${calicoNodeImageRepo}
81 calicoctl_image_repo: ${calicoCtlImageRepo}
82 calico_version: ${calicoVersion}
83 """.stripIndent()
84 } // dir artifacts
Sergey Kulanov247c4e72016-10-17 16:43:29 +030085
86 return [
Sergey Kulanov2202ad22016-10-18 17:14:12 +030087 CTL_CONTAINER_NAME:"${ctlContainerName}",
88 NODE_CONTAINER_NAME:"${nodeContainerName}",
Sergey Kulanov247c4e72016-10-17 16:43:29 +030089 CALICO_NODE_IMAGE_REPO:"${calicoNodeImageRepo}",
90 CALICOCTL_IMAGE_REPO:"${calicoCtlImageRepo}",
91 CALICO_VERSION: "${calicoVersion}"
92 ]
93
94}