blob: 14cbf2b30e3a287dc84e89996efb39968fd48494 [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
Sergey Kulanov3a939c12016-11-28 11:54:35 +02009 // FIXME(skulanov): remove this after complete migration of calico jobs
Sergey Kulanovfaae3862016-11-28 13:27:36 +020010 // def dockerRepo = config.dockerRepo ?: "mcp-k8s.docker.mirantis.net"
Sergey Kulanov3a939c12016-11-28 11:54:35 +020011 // def artifactoryUrl = config.artifactoryURL ?: "https://artifactory.mcp.mirantis.net/projectcalico"
Sergey Kulanov63b78982016-11-28 16:24:27 +020012 def dockerRepo = config.dockerRepo ?: "artifactory.mcp.mirantis.net:5007"
Sergey Kulanov3a939c12016-11-28 11:54:35 +020013 def artifactoryUrl = config.artifactoryURL ?: "https://artifactory.mcp.mirantis.net/artifactory/projectcalico"
Sergey Kulanov247c4e72016-10-17 16:43:29 +030014
15 def nodeImage = config.nodeImage ?: "calico/node"
Artem Panchenko4932b172016-11-08 19:06:03 +020016 def nodeImageTag = config.nodeImageTag ?: "v1.0.0-beta"
Sergey Kulanov247c4e72016-10-17 16:43:29 +030017 def nodeName = "${dockerRepo}/${nodeImage}:${nodeImageTag}"
18
19 def ctlImage = config.ctlImage ?: "calico/ctl"
Artem Panchenko4932b172016-11-08 19:06:03 +020020 def ctlImageTag = config.ctlImageTag ?: "v1.0.0-beta"
Sergey Kulanov247c4e72016-10-17 16:43:29 +030021 def ctlName = "${dockerRepo}/${ctlImage}:${ctlImageTag}"
22
Sergey Kulanov2202ad22016-10-18 17:14:12 +030023 // calico/build goes from {artifactoryUrl}/mcp/libcalico/
24 def buildImage = config.buildImage ?: "${artifactoryUrl}/mcp/libcalico/lastbuild".toURL().text.trim()
25 // calico/felix goes from {artifactoryUrl}/mcp/felix/
26 def felixImage = config.felixImage ?: "${artifactoryUrl}/mcp/felix/lastbuild".toURL().text.trim()
Sergey Kulanov247c4e72016-10-17 16:43:29 +030027
Sergey Kulanov2202ad22016-10-18 17:14:12 +030028 def confdBuildId = config.confdBuildId ?: "${artifactoryUrl}/mcp/confd/lastbuild".toURL().text.trim()
29 def confdUrl = config.confdUrl ?: "${artifactoryUrl}/mcp/confd/confd-${confdBuildId}"
Sergey Kulanov247c4e72016-10-17 16:43:29 +030030
Sergey Kulanov2202ad22016-10-18 17:14:12 +030031 def birdBuildId = config.birdBuildId ?: "${artifactoryUrl}/mcp/calico-bird/lastbuild".toURL().text.trim()
32 def birdUrl = config.birdUrl ?: "${artifactoryUrl}/mcp/calico-bird/bird-${birdBuildId}"
33 def bird6Url = config.bird6Url ?: "${artifactoryUrl}/mcp/calico-bird/bird6-${birdBuildId}"
34 def birdclUrl = config.birdclUrl ?: "${artifactoryUrl}/mcp/calico-bird/birdcl-${birdBuildId}"
Sergey Kulanov247c4e72016-10-17 16:43:29 +030035
Sergey Kulanov00d74342016-10-24 15:22:11 +030036 def gitCommit = sh(returnStdout: true, script: "git rev-parse --short HEAD").trim()
Sergey Kulanov247c4e72016-10-17 16:43:29 +030037
38 def build = "${config.containersBuildId}-${gitCommit}"
39
40 // return values
Sergey Kulanov2202ad22016-10-18 17:14:12 +030041 def calicoNodeImageRepo = "${dockerRepo}/${nodeImage}"
42 def calicoCtlImageRepo = "${dockerRepo}/${ctlImage}"
43 def calicoVersion = "${nodeImageTag}-${build}"
44 def ctlContainerName = "${ctlName}-${build}"
45 def nodeContainerName = "${nodeName}-${build}"
Sergey Kulanov247c4e72016-10-17 16:43:29 +030046
47 // Start build section
48
49 stage ('Build calico/ctl image'){
50 sh """
Sergey Kulanovd7ea0fe2016-11-05 14:00:20 +020051 make calico/ctl \
Sergey Kulanov2202ad22016-10-18 17:14:12 +030052 CTL_CONTAINER_NAME=${ctlContainerName} \
Sergey Kulanov1c15df02016-11-21 16:59:59 +020053 PYTHON_BUILD_CONTAINER_NAME=${buildImage} \
Sergey Kulanov247c4e72016-10-17 16:43:29 +030054 BIRDCL_URL=${birdclUrl}
55 """
56 }
57
Sergey Kulanov9cef9252016-11-07 11:27:50 +000058
Sergey Kulanov247c4e72016-10-17 16:43:29 +030059 stage('Build calico/node'){
60 sh """
Sergey Kulanovd7ea0fe2016-11-05 14:00:20 +020061 make calico/node \
Sergey Kulanov2202ad22016-10-18 17:14:12 +030062 NODE_CONTAINER_NAME=${nodeContainerName} \
Sergey Kulanov1c15df02016-11-21 16:59:59 +020063 PYTHON_BUILD_CONTAINER_NAME=${buildImage} \
Sergey Kulanov247c4e72016-10-17 16:43:29 +030064 FELIX_CONTAINER_NAME=${felixImage} \
65 CONFD_URL=${confdUrl} \
66 BIRD_URL=${birdUrl} \
67 BIRD6_URL=${bird6Url} \
68 BIRDCL_URL=${birdclUrl}
69 """
70 }
71
72
Sergey Kulanov2202ad22016-10-18 17:14:12 +030073 dir("artifacts"){
74 // Save the last build ID
75 writeFile file: "lastbuild", text: "${build}"
76 // Create config yaml for Kargo
77 writeFile file: "calico-containers-${build}.yaml",
78 text: """\
79 calico_node_image_repo: ${calicoNodeImageRepo}
80 calicoctl_image_repo: ${calicoCtlImageRepo}
81 calico_version: ${calicoVersion}
82 """.stripIndent()
83 } // dir artifacts
Sergey Kulanov247c4e72016-10-17 16:43:29 +030084
85 return [
Sergey Kulanov2202ad22016-10-18 17:14:12 +030086 CTL_CONTAINER_NAME:"${ctlContainerName}",
87 NODE_CONTAINER_NAME:"${nodeContainerName}",
Sergey Kulanov247c4e72016-10-17 16:43:29 +030088 CALICO_NODE_IMAGE_REPO:"${calicoNodeImageRepo}",
89 CALICOCTL_IMAGE_REPO:"${calicoCtlImageRepo}",
90 CALICO_VERSION: "${calicoVersion}"
91 ]
92
93}