blob: bb63549e432a1cada2bd7f96c536bc92276cf555 [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 Kulanov6d9a4f82016-11-28 16:37:27 +020012 def dockerRepo = config.dockerRepo ?: "artifactory.mcp.mirantis.net:5001"
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 Kulanov74910b62016-11-28 18:00:17 +020028 def artifactoryBirdUrl = "https://artifactory.mcp.mirantis.net/artifactory/binary-prod-local"
29
Sergey Kulanov4add50c2016-11-29 11:20:42 +020030 def confdBuildId = config.confdBuildId ?: "${artifactoryBirdUrl}/${projectNamespace}/confd/latest".toURL().text.trim()
31 def confdUrl = config.confdUrl ?: "${artifactoryBirdUrl}/${projectNamespace}/confd/confd-${confdBuildId}"
32
Sergey Kulanov74910b62016-11-28 18:00:17 +020033 def birdBuildId = config.birdBuildId ?: "${artifactoryBirdUrl}/${projectNamespace}/bird/latest".toURL().text.trim()
34 def birdUrl = config.birdUrl ?: "${artifactoryBirdUrl}/${projectNamespace}/bird/bird-${birdBuildId}"
35 def bird6Url = config.bird6Url ?: "${artifactoryBirdUrl}/${projectNamespace}/bird/bird6-${birdBuildId}"
36 def birdclUrl = config.birdclUrl ?: "${artifactoryBirdUrl}/${projectNamespace}/bird/birdcl-${birdBuildId}"
Sergey Kulanov247c4e72016-10-17 16:43:29 +030037
Sergey Kulanov00d74342016-10-24 15:22:11 +030038 def gitCommit = sh(returnStdout: true, script: "git rev-parse --short HEAD").trim()
Sergey Kulanov247c4e72016-10-17 16:43:29 +030039
40 def build = "${config.containersBuildId}-${gitCommit}"
41
42 // return values
Sergey Kulanov2202ad22016-10-18 17:14:12 +030043 def calicoNodeImageRepo = "${dockerRepo}/${nodeImage}"
44 def calicoCtlImageRepo = "${dockerRepo}/${ctlImage}"
45 def calicoVersion = "${nodeImageTag}-${build}"
46 def ctlContainerName = "${ctlName}-${build}"
47 def nodeContainerName = "${nodeName}-${build}"
Sergey Kulanov247c4e72016-10-17 16:43:29 +030048
49 // Start build section
50
51 stage ('Build calico/ctl image'){
52 sh """
Sergey Kulanovd7ea0fe2016-11-05 14:00:20 +020053 make calico/ctl \
Sergey Kulanov2202ad22016-10-18 17:14:12 +030054 CTL_CONTAINER_NAME=${ctlContainerName} \
Sergey Kulanov1c15df02016-11-21 16:59:59 +020055 PYTHON_BUILD_CONTAINER_NAME=${buildImage} \
Sergey Kulanov247c4e72016-10-17 16:43:29 +030056 BIRDCL_URL=${birdclUrl}
57 """
58 }
59
Sergey Kulanov9cef9252016-11-07 11:27:50 +000060
Sergey Kulanov247c4e72016-10-17 16:43:29 +030061 stage('Build calico/node'){
62 sh """
Sergey Kulanovd7ea0fe2016-11-05 14:00:20 +020063 make calico/node \
Sergey Kulanov2202ad22016-10-18 17:14:12 +030064 NODE_CONTAINER_NAME=${nodeContainerName} \
Sergey Kulanov1c15df02016-11-21 16:59:59 +020065 PYTHON_BUILD_CONTAINER_NAME=${buildImage} \
Sergey Kulanov247c4e72016-10-17 16:43:29 +030066 FELIX_CONTAINER_NAME=${felixImage} \
67 CONFD_URL=${confdUrl} \
68 BIRD_URL=${birdUrl} \
69 BIRD6_URL=${bird6Url} \
70 BIRDCL_URL=${birdclUrl}
71 """
72 }
73
74
Sergey Kulanov2202ad22016-10-18 17:14:12 +030075 dir("artifacts"){
76 // Save the last build ID
77 writeFile file: "lastbuild", text: "${build}"
78 // Create config yaml for Kargo
79 writeFile file: "calico-containers-${build}.yaml",
80 text: """\
81 calico_node_image_repo: ${calicoNodeImageRepo}
82 calicoctl_image_repo: ${calicoCtlImageRepo}
83 calico_version: ${calicoVersion}
84 """.stripIndent()
85 } // dir artifacts
Sergey Kulanov247c4e72016-10-17 16:43:29 +030086
87 return [
Sergey Kulanov2202ad22016-10-18 17:14:12 +030088 CTL_CONTAINER_NAME:"${ctlContainerName}",
89 NODE_CONTAINER_NAME:"${nodeContainerName}",
Sergey Kulanov247c4e72016-10-17 16:43:29 +030090 CALICO_NODE_IMAGE_REPO:"${calicoNodeImageRepo}",
91 CALICOCTL_IMAGE_REPO:"${calicoCtlImageRepo}",
92 CALICO_VERSION: "${calicoVersion}"
93 ]
94
95}