added svcapi ui and camunda code
Signed-off-by: Rohan Patel <rp5811@att.com>
Change-Id: I197b4b40fe3d047a417479214e471ae26d51fb2b
diff --git a/otf-frontend/Jenkinsfile b/otf-frontend/Jenkinsfile
new file mode 100644
index 0000000..0cc1a01
--- /dev/null
+++ b/otf-frontend/Jenkinsfile
@@ -0,0 +1,153 @@
+#!/usr/bin/env groovy
+
+properties([[$class: 'ParametersDefinitionProperty', parameterDefinitions: [
+[$class: 'hudson.model.StringParameterDefinition', name: 'PHASE', defaultValue: "BUILD"],
+[$class: 'hudson.model.StringParameterDefinition', name: 'ENV', defaultValue: "dev"],
+[$class: 'hudson.model.StringParameterDefinition', name: 'MECHID', defaultValue: "username"],
+[$class: 'hudson.model.StringParameterDefinition', name: 'KUBE_CONFIG', defaultValue: "kubeConfig-dev"],
+[$class: 'hudson.model.StringParameterDefinition', name: 'OTF_MONGO_DB', defaultValue: "otf_mongo_dev_db"],
+[$class: 'hudson.model.StringParameterDefinition', name: 'OTF_CAMUNDA_DB', defaultValue: "otf_camunda_dev_db"],
+[$class: 'hudson.model.StringParameterDefinition', name: 'TILLER_NAMESPACE', defaultValue: ""]
+]]])
+
+echo "Build branch: ${env.BRANCH_NAME}"
+
+node("docker"){
+ stage 'Checkout'
+ checkout scm
+ PHASES=PHASE.tokenize( '_' );
+ echo "PHASES : " + PHASES
+
+
+ ARTIFACT_ID="otf-frontend";
+ VERSION="Camille.1.0.3";
+ //TODO: deal with namespace and docker registry
+ NAMESPACE=""
+ DOCKER_REGISTRY=""
+
+ if( ENV.equalsIgnoreCase("dev") ){
+ IMAGE_NAME=DOCKER_REGISTRY + "/" + NAMESPACE + "/" + ARTIFACT_ID + ":" + VERSION
+ }
+ if( ENV.equalsIgnoreCase("prod") || ENV.equalsIgnoreCase("prod-dr")){
+ IMAGE_NAME=DOCKER_REGISTRY + "/" + NAMESPACE + ".prod" + "/" + ARTIFACT_ID + ":" + VERSION
+ }
+ if( ENV.equalsIgnoreCase("st") ){
+ IMAGE_NAME=DOCKER_REGISTRY + "/" + NAMESPACE + ".st" + "/" + ARTIFACT_ID + ":" + VERSION
+ }
+ echo "Artifact: " + IMAGE_NAME
+
+ withEnv(["PATH=${env.PATH}:${env.WORKSPACE}/linux-amd64", "HELM_HOME=${env.WORKSPACE}"]) {
+
+ echo "PATH=${env.PATH}"
+ echo "HELM_HOME=${env.HELM_HOME}"
+
+ withCredentials([usernamePassword(credentialsId: MECHID, usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
+
+ // sh """
+ // docker login $DOCKER_REGISTRY --username $USERNAME --password $PASSWORD
+ // """
+
+ if (PHASES.contains("BUILD")){
+ stage 'Publish Artifact'
+
+
+ echo "Artifact: " + IMAGE_NAME
+
+ sh """
+ docker login $DOCKER_REGISTRY --username $USERNAME --password $PASSWORD
+ docker build --no-cache -t $IMAGE_NAME .
+ docker push $IMAGE_NAME
+ """
+
+
+ }
+ }
+
+ if (PHASES.contains("DEPLOY") || PHASES.contains("UNDEPLOY")) {
+
+ stage 'Init Helm'
+
+ //check if helm exists if not install
+ if(fileExists('linux-amd64/helm')){
+ sh """
+ echo "helm is already installed"
+ """
+ }
+ else{
+ //download helm
+ sh """
+ echo "installing helm"
+ wget https://storage.googleapis.com/kubernetes-helm/helm-v2.8.2-linux-amd64.tar.gz
+ tar -xf helm-v2.8.2-linux-amd64.tar.gz
+ rm helm-v2.8.2-linux-amd64.tar.gz
+ """
+ }
+
+ withCredentials([file(credentialsId: KUBE_CONFIG, variable: 'KUBECONFIG')]) {
+
+ dir('helm'){
+ //check if charts are valid, and then perform dry run, if successful then upgrade/install charts
+
+ if (PHASES.contains("UNDEPLOY") ) {
+ stage 'Undeploy'
+
+ sh """
+ helm delete --tiller-namespace=$TILLER_NAMESPACE --purge $ARTIFACT_ID
+ """
+ }
+
+ //NOTE Double quotes are used below to access groovy variables like artifact_id and tiller_namespace
+ if (PHASES.contains("DEPLOY") ){
+ stage 'Deploy'
+ withCredentials([
+ usernamePassword(credentialsId: OTF_MONGO_DB, usernameVariable: 'USERNAME_MONGO', passwordVariable: 'PASSWORD_MONGO'),
+ usernamePassword(credentialsId: 'FEATHERS_AUTH', usernameVariable: 'USER', passwordVariable: 'AUTHENTICATION_SECRET')
+ ]) {
+
+ sh """
+ echo "Validate Yaml"
+ helm lint $ARTIFACT_ID
+
+ echo "View Helm Templates"
+ helm template $ARTIFACT_ID \
+ --set appName=$ARTIFACT_ID \
+ --set version=$VERSION \
+ --set image=$IMAGE_NAME \
+ --set namespace=$TILLER_NAMESPACE \
+ --set env=$ENV \
+ --set AUTHENTICATION_SECRET=$AUTHENTICATION_SECRET \
+ --set mongo.username=$USERNAME_MONGO \
+ --set mongo.password=$PASSWORD_MONGO
+
+ echo "Perform Dry Run Of Install"
+ helm upgrade --tiller-namespace=$TILLER_NAMESPACE --install --dry-run $ARTIFACT_ID $ARTIFACT_ID \
+ --set appName=$ARTIFACT_ID \
+ --set version=$VERSION \
+ --set image=$IMAGE_NAME \
+ --set namespace=$TILLER_NAMESPACE \
+ --set env=$ENV \
+ --set AUTHENTICATION_SECRET=$AUTHENTICATION_SECRET \
+ --set mongo.username=$USERNAME_MONGO \
+ --set mongo.password=$PASSWORD_MONGO
+
+ echo "Helm Install/Upgrade"
+ helm upgrade --tiller-namespace=$TILLER_NAMESPACE --install --timeout 1000 $ARTIFACT_ID $ARTIFACT_ID \
+ --set appName=$ARTIFACT_ID \
+ --set version=$VERSION \
+ --set image=$IMAGE_NAME \
+ --set namespace=$TILLER_NAMESPACE \
+ --set env=$ENV \
+ --set AUTHENTICATION_SECRET=$AUTHENTICATION_SECRET \
+ --set mongo.username=$USERNAME_MONGO \
+ --set mongo.password=$PASSWORD_MONGO
+
+ """
+ }
+ }
+
+ }
+ }
+ }
+
+ }
+}