blob: 7737296f4ce21f8b81eb18c103893b0bf0c5fb3a [file] [log] [blame]
Zsolt Haraszti56700cd2016-06-01 16:02:05 -07001/*
Zsolt Harasztid5fa9ed2016-06-01 16:07:16 -07002 * Copyright 2012 the original author or authors.
Zsolt Haraszti56700cd2016-06-01 16:02:05 -07003 *
Zsolt Harasztid5fa9ed2016-06-01 16:07:16 -07004 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
Zsolt Haraszti56700cd2016-06-01 16:02:05 -070015 */
16
Zsolt Harasztid5fa9ed2016-06-01 16:07:16 -070017ext {
Zsolt Haraszti56700cd2016-06-01 16:02:05 -070018
Zsolt Harasztid5fa9ed2016-06-01 16:07:16 -070019 // Target registry to be used to publish docker images needed for deployment
20 targetReg = project.hasProperty('targetReg') ? project.getProperty('targetReg') : 'localhost:5000'
21
22 // The tag used to tag the docker images push to the target registry
23 targetTag = project.hasProperty('targetTag') ? project.getProperty('targetTag') : 'candidate'
24
ChetanGaonker5979e212016-06-03 09:30:49 -070025 cordTesterPath = project.hasProperty('cordTesterPath') ? project.getProperty('cordTesterPath') : './src/test/setup'
26
27 dockerPath = project.hasProperty('dockerPath') ? project.getProperty('dockerPath') : '/usr/bin'
A R Karthick577520a2016-06-07 14:40:12 -070028
A.R Karthick490f51f2016-06-09 21:29:13 -070029 cordTesterImages = [ 'cord-test/radius:latest' : 'Dockerfile.radius', 'cord-test/quagga:latest' : 'Dockerfile.quagga', 'cord-test/nose:latest' : 'Dockerfile.tester' ]
A R Karthick4922a672016-08-23 16:51:19 -070030
Zsolt Haraszti56700cd2016-06-01 16:02:05 -070031}
32
Zsolt Harasztid5fa9ed2016-06-01 16:07:16 -070033// ~~~~~~~~~~~~~~~~~~~ Global tasks ~~~~~~~~~~~~~~~~~~~~~~~
Zsolt Haraszti56700cd2016-06-01 16:02:05 -070034
Zsolt Harasztid5fa9ed2016-06-01 16:07:16 -070035// To be used to fetch upstream binaries, clone repos, etc.
A.R Karthick490f51f2016-06-09 21:29:13 -070036task fetch {
37 //commandLine "$cordTesterPath/onos_pull.sh", 'latest'
Zsolt Haraszti56700cd2016-06-01 16:02:05 -070038}
Zsolt Harasztid5fa9ed2016-06-01 16:07:16 -070039
40// To be used to generate all needed binaries that need to be present on the target
41// as docker images in the local docker runner.
A.R Karthick490f51f2016-06-09 21:29:13 -070042task buildImages {
Zsolt Harasztid5fa9ed2016-06-01 16:07:16 -070043 // ...
A.R Karthick490f51f2016-06-09 21:29:13 -070044 cordTesterImages.each { tag, dockerfile ->
45 println "Building Docker image ${tag} using ${dockerfile}"
46 exec {
47 executable "$dockerPath/docker"
48 args "build", "-t", "${tag}", "-f", "${dockerfile}", "."
49 }
50 }
Zsolt Harasztid5fa9ed2016-06-01 16:07:16 -070051}
52
A R Karthick4922a672016-08-23 16:51:19 -070053task buildRadiusImage(type: Exec) {
54 commandLine "$dockerPath/docker", 'build', '-t', 'cord-test/radius', '-f', 'Dockerfile.radius', '.'
55}
56
57task tagRadiusImage(type: Exec) {
58 dependsOn buildRadiusImage
59 commandLine "$dockerPath/docker", 'tag', 'cord-test/radius', "$targetReg/cord-test/radius:$targetTag"
60}
61
62task publishRadiusImage(type: Exec) {
63 dependsOn tagRadiusImage
64 commandLine "$dockerPath/docker", 'push', "$targetReg/cord-test/radius:$targetTag"
65}
66
67task buildQuaggaImage(type: Exec) {
68 commandLine "$dockerPath/docker", 'build', '-t', 'cord-test/quagga', '-f', 'Dockerfile.quagga', '.'
69}
70
71task tagQuaggaImage(type: Exec) {
72 dependsOn buildQuaggaImage
73 commandLine "$dockerPath/docker", 'tag', 'cord-test/quagga', "$targetReg/cord-test/quagga:$targetTag"
74}
75
76task publishQuaggaImage(type: Exec) {
77 dependsOn tagQuaggaImage
78 commandLine "$dockerPath/docker", 'push', "$targetReg/cord-test/quagga:$targetTag"
79}
80
81task buildTesterImage(type: Exec) {
82 commandLine "$dockerPath/docker", 'build', '-t', 'cord-test/nose', '-f', 'Dockerfile.tester', '.'
83}
84
85task tagTesterImage(type: Exec) {
86 dependsOn buildTesterImage
87 commandLine "$dockerPath/docker", 'tag', 'cord-test/nose', "$targetReg/cord-test/nose:$targetTag"
88}
89
90task publishTesterImage(type: Exec) {
91 dependsOn tagTesterImage
92 commandLine "$dockerPath/docker", 'push', "$targetReg/cord-test/nose:$targetTag"
93}
94
Zsolt Harasztid5fa9ed2016-06-01 16:07:16 -070095// Publish image(s) built during the build step into targetReg registry using the targetTag
96// tag. See maas subproject for examples on how to do this.
A R Karthick4922a672016-08-23 16:51:19 -070097task publishImages {
98 dependsOn publishTesterImage
99 dependsOn publishQuaggaImage
100 dependsOn publishRadiusImage
101}
102
Zsolt Harasztid5fa9ed2016-06-01 16:07:16 -0700103task publish {
A R Karthick4922a672016-08-23 16:51:19 -0700104 dependsOn publishImages
Zsolt Harasztid5fa9ed2016-06-01 16:07:16 -0700105}