Skip to content

Commit

Permalink
Merge pull request #530 from tmobile/v1.8.1
Browse files Browse the repository at this point in the history
Release v1.9
  • Loading branch information
suryajak authored Aug 24, 2018
2 parents a758558 + 557918d commit 67d6100
Show file tree
Hide file tree
Showing 760 changed files with 8,275 additions and 3,739 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# ![Jazz Logo](misc/logo.png) Jazz Serverless Platform

[![Build Status](https://travis-ci.org/tmobile/jazz.svg?branch=master)](https://travis-ci.org/tmobile/jazz)
[![License](https://img.shields.io/badge/License-Apache%202.0-yellowgreen.svg)](https://github.com/tmobile/jazz/blob/master/LICENSE)

**Seamlessly build, deploy & manage cloud-native applications.**

Jazz accelerates adoption of serverless services. Jazz comes with a UI that lets developers quickly create serverless services with the click of a button. Its modular design makes it easy to add new integrations:
Jazz accelerates adoption of serverless services. Jazz comes with a UI that lets developers quickly create serverless services with the click of a button. Its modular design makes it easy to add new integrations.

* **Services** - Jazz can help build functions, APIs and static websites. The template-based system makes it easy to define new ones.
* **Deployment Targets** - Currently we deploy to AWS (Lambda, API gateway and S3). We plan to support Azure Functions and Docker containers in the near future.
Expand All @@ -30,4 +31,4 @@ For more details, see the [Wiki](https://github.com/tmobile/jazz/wiki).

## License

Jazz is released under the [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0).
Jazz is released under the [Apache 2.0 License](https://github.com/tmobile/jazz/blob/master/LICENSE)
31 changes: 23 additions & 8 deletions builds/delete-serverless-service-build-pack/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ node {
try {
def branch = environmentMetadataLoader.getEnvironmentBranchName(_envId)
if (branch && branch != 'NA') {
environmentMetadataLoader.setBranch(branch)
events.setBranch(branch)
sonarModule.setBranch(branch)
branch = 'NA'
Expand All @@ -159,7 +160,7 @@ node {
cleanUpApiDocs(_envId)
unDeployService(_envId)
if (configLoader.CODE_QUALITY.SONAR.ENABLE_SONAR == "true" && configLoader.CODE_QUALITY.SONAR.CLEANUP == "true") {
cleanupCodeQualityReports()
cleanupCodeQualityReports()
}
events.sendCompletedEvent('DELETE_ENVIRONMENT', "Environment cleanup for " + _envId + " completed", null, _envId)
} catch (ex) {
Expand Down Expand Up @@ -189,7 +190,7 @@ node {
echo 'undeploying function for environment: ' + _envId
unDeployService(_envId)
if (configLoader.CODE_QUALITY.SONAR.ENABLE_SONAR == "true" && configLoader.CODE_QUALITY.SONAR.CLEANUP == "true") {
cleanupCodeQualityReports()
cleanupCodeQualityReports()
}
events.sendCompletedEvent('DELETE_ENVIRONMENT', "Environment cleanup for " + _envId + " completed", null, _envId)
} catch (ex) {
Expand Down Expand Up @@ -246,7 +247,7 @@ def cleanupCodeQualityReports(){
try {
sonarModule.cleanupCodeQualityReports()
} catch (ex) {
echo "error occured while deleting code quality reports: " + ex.getMessage()
echo "error occured while deleting code quality reports: " + ex.getMessage()
}
}

Expand Down Expand Up @@ -427,9 +428,11 @@ def cleanUpApiGatewayResources(stage, path) {
current_environment = 'prod'
}
echo "Resource search key for ApiGateway : $resource_search_key"
def aws_api_id = getApiId(stage)

try {
def outputStr = sh(
script: "aws apigateway get-resources --rest-api-id ${getApiId(stage)} --region ${configLoader.AWS.REGION} --output json",
script: "aws apigateway get-resources --rest-api-id ${aws_api_id} --region ${configLoader.AWS.REGION} --output json",
returnStdout: true
).trim()

Expand All @@ -444,18 +447,18 @@ def cleanUpApiGatewayResources(stage, path) {
}
if (resource_id != null && resource_id != "") {
def status_json = sh(
script: "aws apigateway delete-resource --rest-api-id ${getApiId(stage)} --region ${configLoader.AWS.REGION} --resource-id ${resource_id} --output json",
script: "aws apigateway delete-resource --rest-api-id ${aws_api_id} --region ${configLoader.AWS.REGION} --resource-id ${resource_id} --output json",
returnStdout: true
).trim()
try {
def deployment_status_json = sh(
script: "aws apigateway create-deployment --rest-api-id ${getApiId(stage)} --region ${configLoader.AWS.REGION} --stage-name ${current_environment} --description 'API deployment after resource clean up' --output json",
script: "aws apigateway create-deployment --rest-api-id ${aws_api_id} --region ${configLoader.AWS.REGION} --stage-name ${current_environment} --description 'API deployment after resource clean up' --output json",
returnStdout: true
).trim()
} catch (ex) {
}
} else {
echo "Resource Id does not exists in API gateway."
echo "Resource Id does not exist in API gateway."
}
} catch (ex) {
handleFailureEvent(ex.getMessage())
Expand Down Expand Up @@ -488,12 +491,24 @@ def getServiceBucket(stage) {


/**
* Get the API Id of the gateway specific to an environment. The values will be pulled ENV vars set
* Get the API Id of the gateway specific to an environment. The value will be retrieved from environments table and if not available will try to retrieve it from config
* @param stage the environment
* @return api Id
*/
def getApiId(stage) {
echo "stage: $stage"

def envInfo = environmentMetadataLoader.getEnvironmentInfo()
def envMetadata = [:]

if (envInfo && envInfo["metadata"]) {
envMetadata = envInfo["metadata"]
}

if (envMetadata["AWS_API_ID"] != null) {
return envMetadata["AWS_API_ID"]
}

if (stage.endsWith('-dev')) {
return utilModule.getAPIIdForCore(configLoader.AWS.API["DEV"])
} else if (stage == 'stg') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ import groovy.transform.Field
echo "Environment and deployment metadata module loaded successfully"

/**
* The environment-deployment loader module. This module will load all environment and deployment related metadata from respective tables or Apis
* get it ready for Jenkins builds. It loads data for all service types.
* The environment-deployment loader module. This module will load all environment and deployment related metadata from respective tables or Apis
* get it ready for Jenkins builds. It loads data for all service types.
*/


@Field def g_login_token
@Field def g_service_config
@Field def config_loader
@Field def scm_module
@Field def g_service_branch
@Field def g_service_branch
@Field def g_build_url
@Field def g_build_id
@Field def g_environment_logical_id
Expand All @@ -39,7 +39,6 @@ def initialize(serviceConfig, configLoader, scmMdule, branch, buildUrl, buildId,

def getEnvironmentLogicalId() {
if (g_environment_logical_id == null && g_service_config['domain'] != "jazz") {
def API_ENVIRONMENT_QUERY_URL = "${g_environment_api}?service=${g_service_config['service']}&domain=${g_service_config['domain']}"
def getEnvironments = sh(script: "curl -H \"Content-type: application/json\" -H \"Authorization:\"$g_login_token -X GET \"${g_environment_api}?service=${g_service_config['service']}&domain=${g_service_config['domain']}\" ", returnStdout: true).trim()
def environmentOutput
def environment_logical_id
Expand Down Expand Up @@ -67,6 +66,28 @@ def getEnvironmentLogicalId() {
return g_environment_logical_id
}

def getEnvironmentInfo() {
if (g_service_config['domain'] != "jazz") {
def getEnvironments = sh(script: "curl -H \"Content-type: application/json\" -H \"Authorization:\"$g_login_token -X GET \"${g_environment_api}?service=${g_service_config['service']}&domain=${g_service_config['domain']}\" ", returnStdout: true).trim()
def environmentOutput
def environment_logical_id
if (getEnvironments != null) {
try {
environmentOutput = parseJson(getEnvironments)
} catch (ex) {
error ex.getMessage()
}
if (environmentOutput != null && environmentOutput.data != null && environmentOutput.data.environment != null) {
for (environment in environmentOutput.data.environment) {
if (environment.physical_id.equals(g_service_branch)) {
return environment;
}
}
}
}
}
}

/**
* @param environment_logical_id
*/
Expand All @@ -88,7 +109,7 @@ def createPromotedEnvironment(environment_logical_id, created_by) {
-H 'authorization: $g_login_token' \
-H 'Content-type: application/json' \
-d '$payload'", returnStdout: true)
def resObj
def resObj
if (res) {
resObj = parseJson(res)
}
Expand All @@ -111,11 +132,10 @@ def createPromotedEnvironment(environment_logical_id, created_by) {
* Method to check an env is created with same logical id
* @param environment = logical_id
*/
def checkIfEnvironmentAvailable(environment_logical_id) {
def checkIfEnvironmentAvailable(environment_logical_id) {
def isAvailable = false
try {
if (environment_logical_id && g_service_config['domain'] != "jazz") {
def API_ENVIRONMENT_QUERY_URL = "${g_environment_api}?service=${g_service_config['service']}&domain=${g_service_config['domain']}"
def getEnvironments = sh(script: "curl -H \"Content-type: application/json\" -H \"Authorization:\"$g_login_token -X GET \"${g_environment_api}?service=$s{ervice_config['service']}&domain=${g_service_config['domain']}\" ", returnStdout: true).trim()
def environmentOutput
if (getEnvironments) {
Expand Down Expand Up @@ -197,7 +217,7 @@ def getEnvironmentBranchName(logical_id) {
}
}

def generateEnvironmentMap(status, environment_logical_id) {
def generateEnvironmentMap(status, environment_logical_id, metadata) {
def env_logical_id
if (environment_logical_id == null) {
env_logical_id = getEnvironmentLogicalId()
Expand All @@ -213,6 +233,11 @@ def generateEnvironmentMap(status, environment_logical_id) {
if (g_environment_endpoint != null) {
serviceCtxMap.endpoint = g_environment_endpoint
}

if (metadata != null) {
serviceCtxMap.metadata = metadata
}

return serviceCtxMap;
}

Expand Down Expand Up @@ -279,31 +304,31 @@ def parseJson(def json) {

/**
* Set Service config
* @return
* @return
*/
def setServiceConfig(config) {
g_service_config = config
}

/**
* Set Service config
* @return
* @return
*/
def setConfigLoader(configLoader) {
config_loader = configLoader
}

/**
* Set Scm module
* @return
* @return
*/
def setScmModule(scmModule){
scm_module = scmModule
}

/**
* Set Branch
* @return
* @return
*/
def setBranch(branch) {
g_service_branch = branch
Expand All @@ -312,15 +337,15 @@ def setBranch(branch) {

/**
* Set Branch
* @return
* @return
*/
def setEnvironmentLogicalId(logical_id) {
g_environment_logical_id = logical_id
}

/**
* Set Build Url
* @return
* @return
*/
def setBuildUrl(build_url) {
g_build_url = build_url
Expand All @@ -329,7 +354,7 @@ def setBuildUrl(build_url) {

/**
* Set Build Id
* @return
* @return
*/
def setBuildId(build_id) {
g_build_id = build_id
Expand All @@ -338,31 +363,31 @@ def setBuildId(build_id) {

/**
* Set Service
* @return
* @return
*/
def setAuthToken(token) {
g_login_token = token
}

/**
* Set Environment Endpoint
* @return
* @return
*/
def setEnvironmentEndpoint(endpoint) {
g_environment_endpoint = endpoint
}

/**
* Set Request Id
* @return
* Set Request Id
* @return
*/
def setRequestId(requestId) {
g_request_id = requestId
}

/**
* Set Base Url
* @return
* Set Base Url
* @return
*/
def setBaseUrl(base_url) {
g_environment_api = base_url
Expand Down
Loading

0 comments on commit 67d6100

Please sign in to comment.