blob: a1d816410009d29073daa1bdf54baf756f249115 [file] [log] [blame]
Zsolt Harasztiec7df102016-05-05 13:34:18 -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
Zsolt Haraszti0b790aa2016-05-12 22:33:14 -070017package org.opencord.gradle.rules
Zsolt Harasztiec7df102016-05-05 13:34:18 -070018
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() {
Zsolt Haraszti3dbe6162016-05-12 12:25:56 -070035 'Rule Usage: publish<component-name>'
Zsolt Harasztiec7df102016-05-05 13:34:18 -070036 }
37
38 void apply(String taskName) {
39 if (taskName.startsWith('publish')) {
40 project.task(taskName, type: DockerPushTask) {
41 ext.compName = taskName - 'publish'
Zsolt Harasztia9f72502016-05-12 16:07:03 -070042 println "Publish rule: $taskName + $compName"
43 def tagTask = "tag$compName"
44 println "Tagtask: $tagTask"
45 dependsOn tagTask
Zsolt Haraszti3dbe6162016-05-12 12:25:56 -070046 def spec = project.comps[ext.compName]
47 repositoryName = spec.name + ':' + project.targetTag
Zsolt Harasztiec7df102016-05-05 13:34:18 -070048 registry = project.targetReg
49 }
50 }
51 }
52}