Zsolt Haraszti | 56700cd | 2016-06-01 16:02:05 -0700 | [diff] [blame] | 1 | /* |
Zsolt Haraszti | d5fa9ed | 2016-06-01 16:07:16 -0700 | [diff] [blame] | 2 | * Copyright 2012 the original author or authors. |
Zsolt Haraszti | 56700cd | 2016-06-01 16:02:05 -0700 | [diff] [blame] | 3 | * |
Zsolt Haraszti | d5fa9ed | 2016-06-01 16:07:16 -0700 | [diff] [blame] | 4 | * 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 Haraszti | 56700cd | 2016-06-01 16:02:05 -0700 | [diff] [blame] | 15 | */ |
| 16 | |
Zsolt Haraszti | d5fa9ed | 2016-06-01 16:07:16 -0700 | [diff] [blame] | 17 | ext { |
Zsolt Haraszti | 56700cd | 2016-06-01 16:02:05 -0700 | [diff] [blame] | 18 | |
Zsolt Haraszti | d5fa9ed | 2016-06-01 16:07:16 -0700 | [diff] [blame] | 19 | // 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 | |
ChetanGaonker | 5979e21 | 2016-06-03 09:30:49 -0700 | [diff] [blame] | 25 | cordTesterPath = project.hasProperty('cordTesterPath') ? project.getProperty('cordTesterPath') : './src/test/setup' |
| 26 | |
| 27 | dockerPath = project.hasProperty('dockerPath') ? project.getProperty('dockerPath') : '/usr/bin' |
A R Karthick | 577520a | 2016-06-07 14:40:12 -0700 | [diff] [blame] | 28 | |
A.R Karthick | 490f51f | 2016-06-09 21:29:13 -0700 | [diff] [blame] | 29 | cordTesterImages = [ 'cord-test/radius:latest' : 'Dockerfile.radius', 'cord-test/quagga:latest' : 'Dockerfile.quagga', 'cord-test/nose:latest' : 'Dockerfile.tester' ] |
A R Karthick | 4922a67 | 2016-08-23 16:51:19 -0700 | [diff] [blame^] | 30 | |
Zsolt Haraszti | 56700cd | 2016-06-01 16:02:05 -0700 | [diff] [blame] | 31 | } |
| 32 | |
Zsolt Haraszti | d5fa9ed | 2016-06-01 16:07:16 -0700 | [diff] [blame] | 33 | // ~~~~~~~~~~~~~~~~~~~ Global tasks ~~~~~~~~~~~~~~~~~~~~~~~ |
Zsolt Haraszti | 56700cd | 2016-06-01 16:02:05 -0700 | [diff] [blame] | 34 | |
Zsolt Haraszti | d5fa9ed | 2016-06-01 16:07:16 -0700 | [diff] [blame] | 35 | // To be used to fetch upstream binaries, clone repos, etc. |
A.R Karthick | 490f51f | 2016-06-09 21:29:13 -0700 | [diff] [blame] | 36 | task fetch { |
| 37 | //commandLine "$cordTesterPath/onos_pull.sh", 'latest' |
Zsolt Haraszti | 56700cd | 2016-06-01 16:02:05 -0700 | [diff] [blame] | 38 | } |
Zsolt Haraszti | d5fa9ed | 2016-06-01 16:07:16 -0700 | [diff] [blame] | 39 | |
| 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 Karthick | 490f51f | 2016-06-09 21:29:13 -0700 | [diff] [blame] | 42 | task buildImages { |
Zsolt Haraszti | d5fa9ed | 2016-06-01 16:07:16 -0700 | [diff] [blame] | 43 | // ... |
A.R Karthick | 490f51f | 2016-06-09 21:29:13 -0700 | [diff] [blame] | 44 | 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 Haraszti | d5fa9ed | 2016-06-01 16:07:16 -0700 | [diff] [blame] | 51 | } |
| 52 | |
A R Karthick | 4922a67 | 2016-08-23 16:51:19 -0700 | [diff] [blame^] | 53 | task buildRadiusImage(type: Exec) { |
| 54 | commandLine "$dockerPath/docker", 'build', '-t', 'cord-test/radius', '-f', 'Dockerfile.radius', '.' |
| 55 | } |
| 56 | |
| 57 | task tagRadiusImage(type: Exec) { |
| 58 | dependsOn buildRadiusImage |
| 59 | commandLine "$dockerPath/docker", 'tag', 'cord-test/radius', "$targetReg/cord-test/radius:$targetTag" |
| 60 | } |
| 61 | |
| 62 | task publishRadiusImage(type: Exec) { |
| 63 | dependsOn tagRadiusImage |
| 64 | commandLine "$dockerPath/docker", 'push', "$targetReg/cord-test/radius:$targetTag" |
| 65 | } |
| 66 | |
| 67 | task buildQuaggaImage(type: Exec) { |
| 68 | commandLine "$dockerPath/docker", 'build', '-t', 'cord-test/quagga', '-f', 'Dockerfile.quagga', '.' |
| 69 | } |
| 70 | |
| 71 | task tagQuaggaImage(type: Exec) { |
| 72 | dependsOn buildQuaggaImage |
| 73 | commandLine "$dockerPath/docker", 'tag', 'cord-test/quagga', "$targetReg/cord-test/quagga:$targetTag" |
| 74 | } |
| 75 | |
| 76 | task publishQuaggaImage(type: Exec) { |
| 77 | dependsOn tagQuaggaImage |
| 78 | commandLine "$dockerPath/docker", 'push', "$targetReg/cord-test/quagga:$targetTag" |
| 79 | } |
| 80 | |
| 81 | task buildTesterImage(type: Exec) { |
| 82 | commandLine "$dockerPath/docker", 'build', '-t', 'cord-test/nose', '-f', 'Dockerfile.tester', '.' |
| 83 | } |
| 84 | |
| 85 | task tagTesterImage(type: Exec) { |
| 86 | dependsOn buildTesterImage |
| 87 | commandLine "$dockerPath/docker", 'tag', 'cord-test/nose', "$targetReg/cord-test/nose:$targetTag" |
| 88 | } |
| 89 | |
| 90 | task publishTesterImage(type: Exec) { |
| 91 | dependsOn tagTesterImage |
| 92 | commandLine "$dockerPath/docker", 'push', "$targetReg/cord-test/nose:$targetTag" |
| 93 | } |
| 94 | |
Zsolt Haraszti | d5fa9ed | 2016-06-01 16:07:16 -0700 | [diff] [blame] | 95 | // 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 Karthick | 4922a67 | 2016-08-23 16:51:19 -0700 | [diff] [blame^] | 97 | task publishImages { |
| 98 | dependsOn publishTesterImage |
| 99 | dependsOn publishQuaggaImage |
| 100 | dependsOn publishRadiusImage |
| 101 | } |
| 102 | |
Zsolt Haraszti | d5fa9ed | 2016-06-01 16:07:16 -0700 | [diff] [blame] | 103 | task publish { |
A R Karthick | 4922a67 | 2016-08-23 16:51:19 -0700 | [diff] [blame^] | 104 | dependsOn publishImages |
Zsolt Haraszti | d5fa9ed | 2016-06-01 16:07:16 -0700 | [diff] [blame] | 105 | } |