118 lines
4.9 KiB
Groovy
118 lines
4.9 KiB
Groovy
// Global Variables
|
|
def NAMESPACE
|
|
def K8S_SERVER_URL
|
|
def HTTP_PROXY_URL
|
|
def NOPROXY
|
|
|
|
|
|
// Initialize the varaibles
|
|
def initialize(){
|
|
env.NAMESPACE = "${params.APPLICATION_NAMESPACE}"
|
|
env.K8S_SERVER_URL = "https://" + "${params.K8S_CLUSTER}" + ".masked"
|
|
if (params.K8S_CLUSTER.contains('IAH')){
|
|
env.HTTP_PROXY_URL = "http://masked****masked:masked"
|
|
env.NOPROXY = "masked"
|
|
} else if (params.K8S_CLUSTER.contains('EUDC')) {
|
|
env.HTTP_PROXY_URL = "http://masked****masked:masked"
|
|
env.NOPROXY = "masked"
|
|
} else if (params.K8S_CLUSTER.contains('USDC')) {
|
|
env.HTTP_PROXY_URL = "http://masked****masked:masked"
|
|
env.NOPROXY = "masked"
|
|
}
|
|
}
|
|
|
|
def configureNamespace(){
|
|
echo "Updating namespace ${params.APPLICATION_NAMESPACE} in cluster ${params.K8S_CLUSTER} with data plane id ${params.DATA_PLANE_ID}"
|
|
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 ${params.APPLICATION_NAMESPACE}
|
|
kubectl label namespaces ${params.APPLICATION_NAMESPACE} platform.tibco.com/dataplane-id=${params.DATA_PLANE_ID} --overwrite=true
|
|
"""
|
|
}
|
|
}
|
|
|
|
// Deploy the chart
|
|
def deployConfigureNamespaceChart(){
|
|
echo "Deploying configure namespace chart in cluster ${params.K8S_CLUSTER} in namespace ${params.APPLICATION_NAMESPACE}"
|
|
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 ${params.APPLICATION_NAMESPACE}
|
|
${HELM_HOME}/linux-amd64/helm repo add tibco-platform https://tibcosoftware.github.io/tp-helm-charts --force-update
|
|
${HELM_HOME}/linux-amd64/helm repo list
|
|
${HELM_HOME}/linux-amd64/helm repo update
|
|
${HELM_HOME}/linux-amd64/helm list
|
|
${HELM_HOME}/linux-amd64/helm upgrade -i dp-configure-namespace tibco-platform/dp-configure-namespace --version 1.4.5 \
|
|
--set namespace=${params.APPLICATION_NAMESPACE} \
|
|
--set global.tibco.dataPlaneId=${params.DATA_PLANE_ID} \
|
|
--set global.tibco.primaryNamespaceName=${params.DATA_PLANE_PRIMARY_NAMESPACE} \
|
|
--set global.tibco.serviceAccount=svcacc-tibcoplatform \
|
|
--set global.httpProxy.httpProxyUrl=\"${env.HTTP_PROXY_URL}\" \
|
|
--set global.httpProxy.httpsProxyUrl=\"${env.HTTP_PROXY_URL}\" \
|
|
--set global.httpProxy.noProxy=\"${env.NOPROXY}\"
|
|
${HELM_HOME}/linux-amd64/helm list
|
|
"""
|
|
}
|
|
}
|
|
|
|
pipeline {
|
|
agent {label 'CEVA_LINUX_EXPERIMENT'}
|
|
|
|
environment{
|
|
HELM_HOME=tool name: 'Helm-3.12.0', type: 'com.cloudbees.jenkins.plugins.customtools.CustomTool'
|
|
}
|
|
parameters{
|
|
choice(name: 'K8S_CLUSTER', choices: ['minikube', 'IAH-WEST', 'IAH-EAST','EUDC-WEST', 'EUDC-EAST', 'USDC-WEST', 'USDC-EAST' ], description: 'Pick the right k8s cluster')
|
|
string(name: 'APPLICATION_NAMESPACE', description: 'Application namespace to be configured', trim: true)
|
|
string(name: 'DATA_PLANE_PRIMARY_NAMESPACE', description: 'Namespace where the TIBCO Platform dataplane is running', trim: true)
|
|
string(name: 'DATA_PLANE_ID', description: 'TIBCO Platform Dataplane Id', 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.APPLICATION_NAMESPACE + " " + params.DATA_PLANE_ID
|
|
}
|
|
// Set the variables
|
|
initialize()
|
|
}
|
|
}
|
|
stage('Checkout') {
|
|
steps {
|
|
sh 'printenv'
|
|
checkout([
|
|
$class: 'GitSCM',
|
|
branches : [[name: "origin/master"]],
|
|
doGenerateSubmoduleConfigurations: false,
|
|
extensions: [[$class: 'LocalBranch', localBranch: "**"]],
|
|
submoduleCfg: [],
|
|
userRemoteConfigs: [
|
|
[
|
|
url: 'https://***masked***/eai/ciconfiguration/tibco-platform/application-namespace-registration.git',
|
|
credentialsId: 'ci.server'
|
|
]
|
|
]
|
|
])
|
|
sh "git branch"
|
|
}
|
|
}
|
|
|
|
stage('Deploy') {
|
|
steps {
|
|
configureNamespace()
|
|
deployConfigureNamespaceChart()
|
|
}
|
|
}
|
|
|
|
}
|
|
post {
|
|
always {
|
|
cleanWs()
|
|
}
|
|
}
|
|
}
|