Code Monkey home page Code Monkey logo

ya-cf-app-gradle-plugin's Introduction

Yet another Gradle plugin to deploy an application to Cloud Foundry.

Build Status

The purpose of this plugin is to provide ways to manage the deployment of an application to a Cloud Foundry Environment - Be able to deploy, update, start/stop/restart application, attach/remove routes, create/bind services/CUPS.

"Yet another" because the authoritative source of Cloud Foundry Gradle plugin is expected to be with the CF-Java-Client project.

Using the Plugin

Start by looking at a sample project using the plugin here

Details

  • Add a buildscript dependency:

buildscript {
	ext {
		cfAppVersion = '2.1.0'
	}
	repositories {
		mavenCentral()
		maven { url "https://oss.sonatype.org/content/repositories/releases" }
		maven { url "https://repo.spring.io/release" }
	}
	dependencies {
		classpath("com.github.pivotalservices:ya-cf-app-gradle-plugin:${cfAppVersion}")
	}
}

apply plugin: 'cf-app'

OR Via the new Gradle plugins mechanism:

plugins {
	id "com.github.pivotalservices.cf-app" version "2.1.0"
}
  • Provide the Cloud Foundry connectivity and application details:

cfConfig {
	//CF Details
	ccHost = "api.local.pcfdev.io"
	ccUser = "admin"
	ccPassword = "admin"
	org = "pcfdev-org"
	space = "pcfdev-space"

	//App Details
	name = "cf-show-env"
	host = "cf-show-env"
	filePath = "build/libs/cf-show-env-0.1.2-SNAPSHOT.jar"
	path = ""
	domain = "local.pcfdev.io"
	instances = 2
	memory = 512

	//Env and services
	buildpack = "https://github.com/cloudfoundry/java-buildpack.git"
	environment = ["JAVA_OPTS": "-Djava.security.egd=file:/dev/./urandom", "SPRING_PROFILES_ACTIVE": "cloud"]
	services  = ["mydb"]
}
  • Run the task(s):

./gradlew cf-push
  • Override the values using explicit gradle properties, they follow a cf.* pattern:

./gradlew cf-push -Pcf.name=Green -Pcf.host=demo-time-temp
  • There is one task to retrieve the details of an application (cf-get-app-detail). You can use this task in the following way, say to retrieve the app url’s in a gradle task:

task showAppUrls(dependsOn: "cf-get-app-detail") << {
	print "${project.cfConfig.applicationDetail.urls}"
}

or if you want to run an acceptance test you can define a task alone these lines:

task acceptanceTest(type: Test, dependsOn: "cf-get-app-detail")  {
	doFirst() {
		systemProperty "url", "https://${project.cfConfig.applicationDetail.urls[0]}"
	}
	useJUnit {
		includeCategories 'test.AcceptanceTest'
	}
}
Note
A sample project demonstrating the plugin is availble here

Using the Plugin for a Blue-Green Application Deployment

The plugin natively understands how to perform the steps of a Blue-Green deploy. Just run the following and you should be set for a Blue-Green deploy:

./gradlew cf-push-blue-green

You may want to run smoke tests after a new version of the app with a new route is brought up before replacing the existing app, if so a smoke test dependency can be added in the build.gradle file the following way:

"cf-push-blue-green-1"{finalizedBy "test"}

and run

./gradlew cf-push-blue-green

Using the Plugin for a Autopilot equivalent deployment

The plugin natively understands how to perform the steps of an Autopilot based deploy. Just run the following on the command line:

./gradlew cf-push-autopilot

Creating services

Services can be created and automatically bound to the app in the targeted org and space by providing information the following way:

    cfService {
        name = "p-mysql"
        plan = "512mb"
        instanceName = "test-db"
    }

    cfService {
        name = "p-rabbitmq"
        plan = "standard"
        instanceName = "test-rabbitmq"
        tags = ["tag1", "tag2"]
    }

    cfUserProvidedService {
        instanceName = "mydb1"
        credentials = ["jdbcUri": "someuri1"]
    }

List of all Tasks

Table 1. Tasks
Task Description

cf-push

Pushes an Application to Cloud Foundry

cf-delete-app

Delete an application from Cloud Foundry

cf-delete-route

Delete a route from Cloud Foundry

cf-get-app-detail

Get the application detail from Cloud Foundry

cf-map-route

Add a route for an application

cf-unmap-route

Remove an existing route for an application

cf-rename-app

Rename an applicaiton

cf-start-app

Start an Application

cf-stop-app

Stop an Application

cf-restage-app

Restage an Application

cf-restart-app

Restart an Application

cf-push-autopilot

Push with Autopilot steps

cf-push-blue-green

Push with Blue-Green steps

cf-create-services

Create a set of services

ya-cf-app-gradle-plugin's People

Contributors

bijukunjummen avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.