blob: a1d816410009d29073daa1bdf54baf756f249115 [file] [log] [blame]
alshabib676bef52016-06-02 12:18:32 -07001/*
2 * Copyright 2012 the original author or authors.
3 *
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.
15 */
16
17package org.opencord.gradle.rules
18
19import org.gradle.api.Rule
20import de.gesellix.gradle.docker.tasks.DockerPushTask
21
22
23/**
24 * Gradle Rule class to publish (push) a docker image to a private repo
25 */
26class DockerPublishRule implements Rule {
27
28 def project
29
30 DockerPublishRule(project) {
31 this.project = project
32 }
33
34 String getDescription() {
35 'Rule Usage: publish<component-name>'
36 }
37
38 void apply(String taskName) {
39 if (taskName.startsWith('publish')) {
40 project.task(taskName, type: DockerPushTask) {
41 ext.compName = taskName - 'publish'
42 println "Publish rule: $taskName + $compName"
43 def tagTask = "tag$compName"
44 println "Tagtask: $tagTask"
45 dependsOn tagTask
46 def spec = project.comps[ext.compName]
47 repositoryName = spec.name + ':' + project.targetTag
48 registry = project.targetReg
49 }
50 }
51 }
52}