Initial version
commit
938fee4695
|
|
@ -0,0 +1,119 @@
|
|||
// Global Variables
|
||||
def NAMESPACE
|
||||
def DEPLOYMENT_TYPE
|
||||
def K8S_SERVER_URL
|
||||
|
||||
// Initialize the varaibles
|
||||
def initialize(){
|
||||
env.NAMESPACE = "eai-tibcoplatform-" + "${params.DATAPLANE_NAME.toLowerCase()}"
|
||||
env.DEPLOYMENT_TYPE = "${params.K8S_CLUSTER}" + "-" + "${params.DATAPLANE_NAME.toUpperCase()}"
|
||||
env.K8S_SERVER_URL = "https://" + "${params.K8S_CLUSTER}" + ".**masked**"
|
||||
|
||||
echo "Namespace: ${env.NAMESPACE}, Deployment Type: ${env.DEPLOYMENT_TYPE}, K8S Server URL: ${env.K8S_SERVER_URL}"
|
||||
}
|
||||
|
||||
// Deploy the chart
|
||||
def registerCluster(){
|
||||
def helm_chart_name = "dp-core-infrastructure"
|
||||
def release_name = "${helm_chart_name}"
|
||||
def values_file = "values_" + "${helm_chart_name}" + ".yaml"
|
||||
echo "Deploying release ${release_name} on cluster ${params.K8S_CLUSTER} in namespace ${env.NAMESPACE} using values file: ${values_file}"
|
||||
withKubeConfig(caCertificate: '', clusterName: env.K8S_CLUSTER, contextName: env.K8S_CLUSTER, credentialsId: env.K8S_CLUSTER.toLowerCase()+'-jenkins-token', namespace: env.NAMESPACE, serverUrl: env.K8S_SERVER_URL) {
|
||||
sh label: '', script: """
|
||||
kubectl config set-context --current --namespace ${env.NAMESPACE}
|
||||
${HELM_HOME}/linux-386/helm repo add eai-tibco-platform https://tibcosoftware.github.io/tp-helm-charts
|
||||
${HELM_HOME}/linux-386/helm repo list
|
||||
${HELM_HOME}/linux-386/helm repo update
|
||||
${HELM_HOME}/linux-386/helm list
|
||||
${HELM_HOME}/linux-386/helm upgrade -i ${release_name} ${params.REPO}/${helm_chart_name} --set namespace=${env.NAMESPACE} --version ${params.HELM_DP_CORE_INFRA_CHART_VERSION} -f deployments/${env.DEPLOYMENT_TYPE}/${values_file}
|
||||
${HELM_HOME}/linux-386/helm list
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
// Deploy the chart
|
||||
def configureNamespace(){
|
||||
def helm_chart_name = "dp-configure-namespace"
|
||||
def release_name = "${helm_chart_name}"
|
||||
def values_file = "values_" + "${helm_chart_name}" + ".yaml"
|
||||
echo "Deploying release ${release_name} on cluster ${params.K8S_CLUSTER} in namespace ${env.NAMESPACE} using values file: ${values_file}"
|
||||
withKubeConfig(caCertificate: '', clusterName: env.K8S_CLUSTER, contextName: env.K8S_CLUSTER, credentialsId: env.K8S_CLUSTER.toLowerCase()+'-jenkins-token', namespace: env.NAMESPACE, serverUrl: env.K8S_SERVER_URL) {
|
||||
sh label: '', script: """
|
||||
kubectl config set-context --current --namespace ${env.NAMESPACE}
|
||||
echo "Applying DataPlane Label"
|
||||
kubectl label namespaces ${env.NAMESPACE} platform.tibco.com/dataplane-id=${params.HELM_DP_CONFIG_NAMESPACE_DATAPLANE_ID} --overwrite=true
|
||||
echo "DataPlane Label applied"
|
||||
${HELM_HOME}/linux-386/helm repo add eai-tibco-platform https://tibcosoftware.github.io/tp-helm-charts
|
||||
${HELM_HOME}/linux-386/helm repo list
|
||||
${HELM_HOME}/linux-386/helm version
|
||||
${HELM_HOME}/linux-386/helm repo update
|
||||
${HELM_HOME}/linux-386/helm list
|
||||
${HELM_HOME}/linux-386/helm upgrade -i ${release_name} ${params.REPO}/${helm_chart_name} --set namespace=${env.NAMESPACE} --version ${params.HELM_DP_CONFIG_NAMESPACE_CHART_VERSION} -f deployments/${env.DEPLOYMENT_TYPE}/${values_file}
|
||||
${HELM_HOME}/linux-386/helm list
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
pipeline {
|
||||
agent {label 'CEVA_LINUX_EXPERIMENT'}
|
||||
|
||||
environment{
|
||||
HELM_HOME=tool name: 'HELM3', type: 'com.cloudbees.jenkins.plugins.customtools.CustomTool'
|
||||
}
|
||||
parameters{
|
||||
string(name: 'SOURCE_TAG', defaultValue: 'master', description: 'Please enter the GIT branch', trim: true)
|
||||
choice(name: 'DATAPLANE_NAME', choices: ['poc','devhub','dev', 'sit','uat', 'prod'], description: 'Please select the correct dataplane envrionment name')
|
||||
choice(name: 'K8S_CLUSTER', choices: ['IAH-WEST', 'IAH-EAST','EUDC-WEST', 'EUDC-EAST', 'USDC-WEST', 'USDC-EAST' ], description: 'Pick the right k8s cluster')
|
||||
choice(name: 'REPO', choices: ['stable', 'incubator','eai-tibco-platform'], description: 'repository type')
|
||||
string(name: 'HELM_DP_CONFIG_NAMESPACE_DATAPLANE_ID', description: 'DataPlane ID used for labeling the namespaces', trim: true)
|
||||
string(name: 'HELM_DP_CONFIG_NAMESPACE_CHART_VERSION', description: 'Version of the DP configure namespace to be deployed', trim: true)
|
||||
string(name: 'HELM_DP_CORE_INFRA_CHART_VERSION', description: 'Version of the DP Core Infrastructure to be deployed', trim: true)
|
||||
}
|
||||
stages {
|
||||
stage('Initialize') {
|
||||
steps {
|
||||
// cleanup workspace before every build
|
||||
deleteDir()
|
||||
|
||||
script{
|
||||
// set the displayName for the build
|
||||
currentBuild.displayName = "#" + env.BUILD_NUMBER + " " + params.K8S_CLUSTER + " " + params.DATAPLANE_NAME + " " + params.HELM_DP_CONFIG_NAMESPACE_CHART_VERSION + " " + params.HELM_DP_CORE_INFRA_CHART_VERSION
|
||||
}
|
||||
// Set the variables
|
||||
initialize()
|
||||
}
|
||||
}
|
||||
stage('Checkout') {
|
||||
steps {
|
||||
sh 'printenv'
|
||||
checkout([
|
||||
$class: 'GitSCM',
|
||||
branches : [[name: "origin/${params.SOURCE_TAG}"]],
|
||||
doGenerateSubmoduleConfigurations: false,
|
||||
extensions: [[$class: 'LocalBranch', localBranch: "**"]],
|
||||
submoduleCfg: [],
|
||||
userRemoteConfigs: [
|
||||
[
|
||||
url: 'https://gitlab.**masked**/k8s/projects/tibco-platform.git',
|
||||
credentialsId: 'ci.server'
|
||||
]
|
||||
]
|
||||
])
|
||||
sh "git branch"
|
||||
}
|
||||
}
|
||||
|
||||
stage('Deploy') {
|
||||
steps {
|
||||
configureNamespace()
|
||||
registerCluster()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
post {
|
||||
always {
|
||||
cleanWs()
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue