blob: d62aadba984423be4a7f6ce893e5eef3be74a481 [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"
Artem Panchenko4932b172016-11-08 19:06:03 +020013 def nodeImageTag = config.nodeImageTag ?: "v1.0.0-beta"
Sergey Kulanov247c4e72016-10-17 16:43:29 +030014 def nodeName = "${dockerRepo}/${nodeImage}:${nodeImageTag}"
15
16 def ctlImage = config.ctlImage ?: "calico/ctl"
Artem Panchenko4932b172016-11-08 19:06:03 +020017 def ctlImageTag = config.ctlImageTag ?: "v1.0.0-beta"
Sergey Kulanov247c4e72016-10-17 16:43:29 +030018 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 Kulanov1c15df02016-11-21 16:59:59 +020050 PYTHON_BUILD_CONTAINER_NAME=${buildImage} \
Sergey Kulanov247c4e72016-10-17 16:43:29 +030051 BIRDCL_URL=${birdclUrl}
52 """
53 }
54
Sergey Kulanov9cef9252016-11-07 11:27:50 +000055
Sergey Kulanov247c4e72016-10-17 16:43:29 +030056 stage('Build calico/node'){
57 sh """
Sergey Kulanovd7ea0fe2016-11-05 14:00:20 +020058 make calico/node \
Sergey Kulanov2202ad22016-10-18 17:14:12 +030059 NODE_CONTAINER_NAME=${nodeContainerName} \
Sergey Kulanov1c15df02016-11-21 16:59:59 +020060 PYTHON_BUILD_CONTAINER_NAME=${buildImage} \
Sergey Kulanov247c4e72016-10-17 16:43:29 +030061 FELIX_CONTAINER_NAME=${felixImage} \
62 CONFD_URL=${confdUrl} \
63 BIRD_URL=${birdUrl} \
64 BIRD6_URL=${bird6Url} \
65 BIRDCL_URL=${birdclUrl}
66 """
67 }
68
69
Sergey Kulanov2202ad22016-10-18 17:14:12 +030070 dir("artifacts"){
71 // Save the last build ID
72 writeFile file: "lastbuild", text: "${build}"
73 // Create config yaml for Kargo
74 writeFile file: "calico-containers-${build}.yaml",
75 text: """\
76 calico_node_image_repo: ${calicoNodeImageRepo}
77 calicoctl_image_repo: ${calicoCtlImageRepo}
78 calico_version: ${calicoVersion}
79 """.stripIndent()
80 } // dir artifacts
Sergey Kulanov247c4e72016-10-17 16:43:29 +030081
82 return [
Sergey Kulanov2202ad22016-10-18 17:14:12 +030083 CTL_CONTAINER_NAME:"${ctlContainerName}",
84 NODE_CONTAINER_NAME:"${nodeContainerName}",
Sergey Kulanov247c4e72016-10-17 16:43:29 +030085 CALICO_NODE_IMAGE_REPO:"${calicoNodeImageRepo}",
86 CALICOCTL_IMAGE_REPO:"${calicoCtlImageRepo}",
87 CALICO_VERSION: "${calicoVersion}"
88 ]
89
90}