CORD-1000 Build and publish XOS images on corddev
Change-Id: I6491b43e518abb8a56aec98b5a71e8d293fc7ef9
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000..d198080
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,51 @@
+import org.yaml.snakeyaml.Yaml
+
+ext {
+
+ // Deployment target config file (yaml format); this can be overwritten from the command line
+ // using the -PdeployConfig=<file-path> syntax.
+ deployConfig = project.hasProperty('deployConfig') ? project.getProperty('deployConfig') : './config/default.yml'
+
+ println "Using deployment config: $deployConfig"
+ File configFile = new File(deployConfig)
+ def yaml = new Yaml()
+ config = yaml.load(configFile.newReader())
+
+ // Upstream registry to simplify filling out the comps table below
+ upstreamReg = project.hasProperty('upstreamReg') ? project.getProperty('upstreamReg') : 'docker.io'
+
+ // Target registry to be used to publish docker images needed for deployment
+ targetReg = project.hasProperty('targetReg')
+ ? project.getProperty('targetReg')
+ : config.docker && config.docker.registry
+ ? config.docker.registry
+ : config.headnode.ip
+ ? config.headnode.ip + ":5000"
+ : 'localhost:5000'
+
+ // The tag used to tag the docker images push to the target registry
+ targetTag = project.hasProperty('targetTag')
+ ? project.getProperty('targetTag')
+ : config.docker && config.docker.imageVersion
+ ? config.docker.imageVersion
+ : 'candidate'
+}
+
+task buildImages(type: Exec) {
+ executable = "ansible-playbook"
+ args = [
+ "--extra-vars", "@../../build/genconfig/config.yml",
+ "--extra-vars", "build_docker_tag="+targetTag,
+ "--extra-vars", "cord_dir=../..",
+ "build-xos-playbook.yml" ]
+}
+
+task publish(type: Exec) {
+ executable = "ansible-playbook"
+ args = [ "-i", "../../build/genconfig/cord-inv",
+ "--extra-vars", "@../../build/genconfig/config.yml",
+ "--extra-vars", "build_docker_tag="+targetTag,
+ "--extra-vars", "deploy_docker_tag="+targetTag,
+ "--extra-vars", "deploy_docker_registry="+targetReg,
+ "publish-xos-playbook.yml" ]
+}