You can use a CI/CD pipeline for exporting the Adeptia Connect objects from one environment to another automatically. The CI/CD pipeline uses the the Export XML file file that you must have created as a prerequisite for export operation, and generates an exported ZIP that contains the objects you want to migrate. After you create the Exported ZIP from the source environment, you need to import the objects to the new environment by by running the import pipeline.
Table of Contents | ||||
---|---|---|---|---|
|
How the Export pipeline works
The diagram below represents how the export pipeline works, and automates the export process.
When triggered, the pipeline performs the following sequence of actions.
...
After you create the pipeline, you need to trigger the pipeline to perform the export operation.
Creating and triggering the Export pipeline
To create the pipeline in Jenkins using the export pipeline provided by Adeptia, follow follow the steps given below.
Log in to the the Jenkins with with admin privileges.
Select New Item.
Enter a name for the Export pipeline, and then select then select Pipeline.
Click Click OK.
Copy the content the content from the provided export provided export pipeline file.
Warningexpand Code Block title Important If you are using Jenkins on Windows OS, and have created an agent on Linux OS, you need to uncomment the following code snippet in the export pipeline file.
Export Pipeline Code Block language css theme Midnight /* agent { label 'LinuxAgent' } */
Expand title Export Pipeline Code Block language css theme Midnight import jenkins.model.Jenkins import java.nio.file.Path; import java.nio.file.import jenkins.model.Jenkins import java.nio.file.Path; import java.nio.file.Paths; import java.io.File; /* This pipeline used to deploys migration promotion through operations like export from one build environment to another. Pipeline is made up of following steps 1. Init Perameters 2. Pull export XML file from GitHub 3. Upload XML to k8 shared PVC 4. Download Helm chart & deploy migration (export) 5. Download solution zip from k8 shared PVC 6. Push soution zip to GitHub 7. Clean up workspace Pre-requisite a) Tools/Plugins needs to install: 1. Helm 2. kubectl client 3. Jenkins 4. Java 1.8+ b) OS Linux c) Jenkins plugins 1. Kubernetes 2. Nexus 3. Git (git plugin 4.8.3, Git client plugin 3.9.0) 43. Mask Password 54. Credentials Binding Plugin (1.27) 65. Parameter Separator 76. BlueOcean (Optional) Usage: Steps to create pipeline using jenkinsfile. 1. Login into the Jenkins GUI with admin privileges. 2. create a pipeline by choosing New Item > Pipeline. 3. Copy/past containt of jenkinsfile to Pipeline Definition area. 4. Uncheck checkbox "Use Groovy Sandbox". 5. Save the pipeline. 6. Trigger the pipeline once to initilaize parameters. */ /* Upload file to Kubernetes PVC */ def uploadToSharedPVC (NAMESPACE, CLUSTER_CONTEXT, K8_CREDENTIALS_ID, SERVER_URL, SRC_FILE_PATH, TRG_FILE_PATH) { echo "Upload file("+SRC_FILE_PATH+") to K8 files to K8 shared PVC" withKubeConfig([credentialsId: K8_CREDENTIALS_ID, serverUrl: SERVER_URL]) { try { wrap([$class: 'MaskPasswordsBuildWrapper', varPasswordPairs: [[NEXUS_PASSWORD:'NEXUS_PASSWORD']]]) { sh ''' #!/bin/shbash kubectl config use-context '''+CLUSTER_CONTEXT+''' TRG_FILE_PATH='''+TRG_FILE_PATH+''' if [[ ${TRG_FILE_PATH::1} == "/" ]] then TRG_FILE_PATH=${TRG_FILE_PATH:1}; else echo "Forward shash(/) already removed "; fi podname=$(kubectl -n '''+NAMESPACE+''' get pods | grep -m 1 autoscaler | awk '{print $1}') kubectl -n '''+NAMESPACE+''' cp '''+SRC_FILE_PATH+''' ${podname}:${TRG_FILE_PATH} jobname=$(kubectl -n '''+NAMESPACE+''' get jobs | grep -m 1 migration | awk '{print $1}') if [[ -n "$jobname" ]]; then kubectl -n '''+NAMESPACE+''' delete job ${jobname} else echo "Migration resource does not exist" fi ''' } } catch (err) { echo "Caught: ${err}. Error in uploading file." error("Caught: ${err}") currentBuild.result = 'FAILURE' } } } /* Download file from Kubernetes PVC */ def downloadFromSharedPVC (NAMESPACE, CLUSTER_CONTEXT, K8_CREDENTIALS_ID, SERVER_URL, SRC_FILE_PATH, TRG_FILE_PATH) { echo "Download file("+SRC_FILE_PATH+")files from K8 shared PVC" withKubeConfig([credentialsId: K8_CREDENTIALS_ID, serverUrl: SERVER_URL]) { try { sh '''#!/bin/bash #!/bin/sh SRCSRC_FILE_PATH='''+SRC_FILE_PATH+''' if [[ ${SRC_FILE_PATH::1} == "/" ]] then SRC_FILE_PATH=${SRC_FILE_PATH:1}; else echo "Forward shash(/) already removed "; fi kubectl config use-context '''+CLUSTER_CONTEXT+''' podname=$(kubectl -n '''+NAMESPACE+''' get pods | grep -m 1 autoscaler | awk '{print $1}') kubectl -n '''+NAMESPACE+''' cp ${podname}:${SRC_FILE_PATH} '''+TRG_FILE_PATH+''' ''' } catch (err) { echo "Caught: ${err}. Error in downloading file from K8 PVC." error("Caught: ${err}") currentBuild.result = 'FAILURE' } } } /* Pull Helm Chart */ def pullHelmChart (HELM_REPO_URL, CHART_NAME) { echo "Pull Helm Chart ("+CHART_NAME+") from Artifact Hub" //withCredentials([usernamePassword(credentialsId: NEXUS_CREDENTIALS_ID, passwordVariable: 'NEXUS_PASSWORD', usernameVariable: 'NEXUS_USERNAME')]) { try { sh '''#!/bin/hide password field bash //wrap([$class: 'MaskPasswordsBuildWrapper', varPasswordPairs: [[NEXUS_PASSWORD:'NEXUS_PASSWORD']]]) { sh ''' #!/bin/sh helm repo add adeptiahelm repo add adeptia-connect-migration '''+HELM_REPO_URL+''' helm pull adeptia-connect-migration/'''+CHART_NAME+''' --untar ''' //} } catch (err) { echo "Caught: ${err}. Error in pulling Helm chart from repo." error("Caught: ${err}") currentBuild.result = 'FAILURE' } // } } /* Deploy Helm to Kubernetes cluster */ def deployToCluster (NAMESPACE, CLUSTER_CONTEXT, K8_CREDENTIALS_ID, DATABASE_CREDENTIALS_ID, SERVER_URL, EXPORT_ZIP_PATH, MIGRATION_XML_FILE_PATH) { echo "Deploy Helm chart to Kubernetes cluster" try { def BACKEND_DB_USERNAME = getUserName(DATABASE_CREDENTIALS_ID); def BACKEND_DB_PASSWORD = getPassword(DATABASE_CREDENTIALS_ID); withKubeConfig([credentialsId: K8_CREDENTIALS_ID, serverUrl: SERVER_URL]) { //hide password field wrap([$class: 'MaskPasswordsBuildWrapper', varPasswordPairs: [[password:BACKEND_DB_PASSWORD], [password:BACKEND_DB_USERNAME]]]) { sh ''' #!/bin/shbash kubectl config use-context '''+CLUSTER_CONTEXT+''' helm upgrade -i migration migration -f migration/values.yaml --set environmentVariables.BACKEND_DB_URL=${BACKEND_DB_URL} --set environmentVariables.BACKEND_DB_USERNAME='''+BACKEND_DB_USERNAME+''' --set environmentVariables.BACKEND_DB_PASSWORD='''+BACKEND_DB_PASSWORD+''' --set environmentVariables.BACKEND_DB_DRIVER_CLASS=${BACKEND_DB_DRIVER_CLASS} --set environmentVariables.BACKEND_DB_TYPE=${BACKEND_DB_TYPE} --set environmentVariables.EXPORT_ZIP_PATH='''+EXPORT_ZIP_PATH+''' --set environmentVariables.MIGRATION_XML_FILE_PATH='''+MIGRATION_XML_FILE_PATH+''' --set environmentVariables.LOG_IDENTIFIER=${LOG_IDENTIFIER} --set environmentVariables.OPERATION=${OPERATION} -n '''+NAMESPACE+''' ''' } } } catch (err) { echo "Caught: ${err}. Error in deploying Helm chart." error("Caught: ${err}") currentBuild.result = 'FAILURE' } } /* Wait until deployment finish on Kubernetes cluster */ def waitUntilDepoymentComplete(NAMESPACE, CLUSTER_CONTEXT, K8_CREDENTIALS_ID, SERVER_URL, POD, time_out) { echo "Fetching pod status" try { int inter = 5, count = 1; withKubeConfig([credentialsId: K8_CREDENTIALS_ID, serverUrl: SERVER_URL]) { sh('kubectl config use-context ${CLUSTER_CONTEXT};') while (true) { def status = sh script: "kubectl -n ${NAMESPACE} get pods | grep -m 1 ${POD} | awk '{print \$3}' ", returnStdout: true if (status.toString().trim().contains("Completed")) { break; } else if (status.toString().trim().contains("Error")) { error("Caught: Migration deployment failed due to error. Please check migration logs.") currentBuild.result = 'FAILURE' sleep(inter) echo count+" retry in "+inter*count+" seconds." count++ if ((count)>=((time_out-5)/inter)) { error("Caught: Migration deployment is taking more then ideal time. Please check migration logs.") currentBuild.result = 'FAILURE' break; break; } } sleep(inter) } } catch (err) { echo count+"Caught: ${err}. Error retry in fetching pod status"+inter*count+" seconds." error("Caught: ${err}") count++ currentBuild.result = 'FAILURE' if ((count)>=((time_out-10)/inter)) { } } /* Push soution Zip to GitHub reposirory */ def pushToGitHub (GIT_BRANCH, GIT_CREDENTIALS_ID, GIT_REPO_URL, FILE_PATH) { error("Caught: Migration deployment taking more then ideal time. Please check migration logs.") currentBuild.result = 'FAILURE' break; } echo "Pushing file ("+FILE_PATH+") to GitHub repo" withCredentials([gitUsernamePassword(credentialsId: GIT_CREDENTIALS_ID, gitToolName: 'git-tool')]) { try { } } sh('sleep 10') sh('git add '+FILE_PATH)} catch (err) { sh('git commit -m "auto commit message" ') echo "Caught: ${err}. Error in fetching pod status. Migration deployment taking more then ideal time. Please check migration logs." sh('git push ${GIT_REPO_URL} HEAD:'+GIT_BRANCHerror("Caught: ${err}") } catch (err) { currentBuild.result = 'FAILURE' echo "Caught: ${err}. Error in pushing file to Github." error("Caught: ${err}") currentBuild.result = 'FAILURE' } } } } } /* Generate rollbackPush soution Zip fileto GitHub pathrepository */ def convertRollbackZipPath(pushToGitHub (GIT_BRANCH, GIT_CREDENTIALS_ID, GIT_REPO_URL, FILE_PATH) { def rollbackZipPath = null echo "Pushing file ("+FILE_PATH+") to GitHub repo" def Append = "Rollback_"withCredentials([gitUsernamePassword(credentialsId: GIT_CREDENTIALS_ID, gitToolName: 'git-tool')]) { try { Pathdef pathgitUser = Paths.get(FILE_PATHgetUserName(GIT_CREDENTIALS_ID); def fileName=path.getFileName().toString() sh('sleep 10') def parentDir=path.getParent().toString() rollbackZipPath=parentDir + File.separator + Append + fileName sh('git config --global user.name "'+gitUser+'"') if(isUnix()){ rollbackZipPath=rollbackZipPath.replace("\\", "/"sh('git config --global user.email "you@example.com"') sh('git add '+FILE_PATH) sh('git commit -m "auto commit message" ') sh('git push ${GIT_REPO_URL} HEAD:'+GIT_BRANCH) } catch (err) { echo "Caught: ${err}. Error in generatingpushing rollbackfile soution Zip file pathto Github." error("Caught: ${err}") currentBuild.result = 'FAILURE' } return rollbackZipPath} } /* Generate Getrollback usernamesoution fromZip credentialsfile idpath */ def getUserNameconvertRollbackZipPath(idFILE_PATH) { def userNamerollbackZipPath = null withCredentials([usernamePassword(credentialsId: id, passwordVariable: 'PASSWORD', usernameVariable: 'USERNAME')]) { def Append = "Rollback_" try { userNamePath path = USERNAMEPaths.get(FILE_PATH); } catch (err) { def fileName=path.getFileName().toString() def parentDir=path.getParent().toString() echo "Caught: ${err}. Error in extracting username from "+id+" ."rollbackZipPath=parentDir + File.separator + Append + fileName error("Caught: ${err}")if(isUnix()){ currentBuild.result = 'FAILURE' rollbackZipPath=rollbackZipPath.replace("\\", "/") } } return userName } catch /*(err) { echo "Caught: ${err}. GetError passwordin fromgenerating credentialsrollback idsoution Zip */ def getPassword(id) { def passwordfile path." error("Caught: ${err}") currentBuild.result = 'FAILURE' } return rollbackZipPath } /* Get username from credentials id */ def getUserName(id) { def userName = null withCredentials([usernamePassword(credentialsId: id, passwordVariable: 'PASSWORD', usernameVariable: 'USERNAME')]) { try { passworduserName = PASSWORD;USERNAME } catch (err) { echo "Caught: ${err}. Error in extracting passwordusername from "+id+" ." error("Caught: ${err}") currentBuild.result = 'FAILURE' } } return passworduserName } /* pipeline { //Get Globalpassword defaultfrom variablescredentials id */ def environmentgetPassword(id) { time_outdef password = 100 } parameters{ //separator(name: 'separator-ce1a9ef5-cd10-4002-a43f-8ae24d9d0bb3', sectionHeader: '''Helm Chart Parameters''', sectionHeaderStyle: 'background-color:#eeeee4;font-size:15px;font-weight:normal;text-transform:uppercase;border-color:gray;', separatorStyle: '''font-weight:bold;line-height:1.5em;font-size:1.5em;''') string(defaultValue: '', description: 'ArtifactHub Helm chart URL e.g. https://adeptia.github.io/adeptia-connect-migration/charts', name: 'HELM_REPO_URL', trim: true) string(defaultValue: '', description: 'Name of Helm chart to be downloaded from ArtifactHub repository e.g. migration', name: 'CHART_NAME', trim: true) //separator(name: null withCredentials([usernamePassword(credentialsId: id, passwordVariable: 'PASSWORD', usernameVariable: 'USERNAME')]) { try { password = PASSWORD; } catch (err) { echo "Caught: ${err}. Error in extracting password from "+id+" ." error("Caught: ${err}") currentBuild.result = 'FAILURE' } } return password } pipeline { // Global default variables environment { //manage deployment status timeout time_out = 300 } parameters{ //separator(name: 'separator-ce1a9ef5-cd10-4002-a43f-8ae24d9d0bb3', sectionHeader: '''GitHubHelm Chart Parameters''', sectionHeaderStyle: 'background-color:#eeeee4;font-size:15px;font-weight:normal;text-transform:uppercase;border-color:gray;', separatorStyle: '''font-weight:bold;line-height:1.5em;font-size:1.5em;''') string(defaultValue: '', description: 'GitHubArtifactHub credentialsHelm ID configured in Jenkinschart URL e.g. gitCredential_idhttps://adeptia.github.io/adeptia-connect-migration/charts', name: 'GITHELM_CREDENTIALSREPO_IDURL', trim: true) string(defaultValue: '', description: 'GitHubName of serverHelm URLchart e.g https://github.com/adeptia/migration-defination.gitto be downloaded from ArtifactHub repository e.g. migration', name: 'GITCHART_REPO_URLNAME', trim: true) string(defaultValue //separator(name: 'separator-ce1a9ef5-cd10-4002-a43f-8ae24d9d0bb3', descriptionsectionHeader: '''GitHub Branch name e.g. main', name: 'GIT_BRANCH', trim: true) string(defaultValue: '', description: 'Path to upload zip file to GitHub. e.g. test/SA_PF.zipParameters''', sectionHeaderStyle: 'background-color:#eeeee4;font-size:15px;font-weight:normal;text-transform:uppercase;border-color:gray;', separatorStyle: '''font-weight:bold;line-height:1.5em;font-size:1.5em;''') string(defaultValue: '', description: 'GitHub credentials ID configured in Jenkins e.g. gitCredential_id', name: 'GIT_EXPORTCREDENTIALS_ZIP_PATHID', trim: true) string(defaultValue: '', description: 'exportGitHub xml file path to download from GitHub.server URL e.g. test/export.xml https://github.com/adeptia/migration-defination.git', name: 'GIT_EXPORTREPO_XML_PATHURL', trim: true) //separatorstring(namedefaultValue: 'separator-ce1a9ef5-cd10-4002-a43f-8ae24d9d0bb3', sectionHeaderdescription: '''Migration Parameters''', sectionHeaderStyle: 'background-color:#eeeee4;font-size:15px;font-weight:normal;text-transform:uppercase;border-color:gray;', separatorStyle: '''font-weight:bold;line-height:1.5em;font-size:1.5em;'''GitHub Branch name e.g. main', name: 'GIT_BRANCH', trim: true) string(defaultValue: '', description: 'LocationPath ofto exportupload xmlzip file to GitHub. ege.g. exporttest/SA_PF.zip', name: 'OPERATION', trim: true) string(defaultValue: '', description: 'Migration export zip path. e.g. /shared/SA_PF.zip', name: 'GIT_EXPORT_ZIP_PATH', trim: true) string(defaultValue: '', description: 'Migration export xml file path to download from GitHub. e.g. test/shared/export.xml', name: 'MIGRATIONGIT_EXPORT_XML_FILE_PATH', trim: true) string//separator(defaultValuename: 'separator-ce1a9ef5-cd10-4002-a43f-8ae24d9d0bb3', descriptionsectionHeader: 'Migration log identifier to capture logs from MS environment.', name: 'LOG_IDENTIFIER', trim: true) //separator(name: 'separator-ce1a9ef5-cd10-4002-a43f-8ae24d9d0bb3', sectionHeader: '''K8 Cluster 'Migration Parameters''', sectionHeaderStyle: 'background-color:#eeeee4;font-size:15px;font-weight:normal;text-transform:uppercase;border-color:gray;', separatorStyle: '''font-weight:bold;line-height:1.5em;font-size:1.5em;''') string(defaultValue: '', description: 'CredentialsLocation IDof configuredexport inxml Jenkinsfile. to access K8 cluster e.g k8credentials', name: 'K8_CREDENTIALS_IDeg. export', name: 'OPERATION', trim: true) string(defaultValue: '', description: 'URLMigration toexport access K8 clusterzip path. e.g. https://*******-dns-2ce021bb.hcp.eastus.azmk8s.io:443shared/SA_PF.zip', name: 'SERVEREXPORT_ZIP_URLPATH', trim: true) string(defaultValue: '', description: 'ClusterMigration contextexport toxml accessfile K8path. cluster e.g. adeptia-context/shared/export.xml', name: 'CLUSTER_CONTEXT'MIGRATION_XML_FILE_PATH', trim: true) string(defaultValue: '', description: 'K8Migration clusterlog nameidentifier spaceto deploymentcapture wherelogs Connectfrom microservices deployed e.g. adeptiaMS environment.', name: 'NAMESPACELOG_IDENTIFIER', trim: true) string(defaultValue //separator(name: 'separator-ce1a9ef5-cd10-4002-a43f-8ae24d9d0bb3', descriptionsectionHeader: '''URLK8 of database backend bind with application.Cluster Parameters''', namesectionHeaderStyle: 'BACKEND_DB_URL', trim: true) background-color:#eeeee4;font-size:15px;font-weight:normal;text-transform:uppercase;border-color:gray;', separatorStyle: '''font-weight:bold;line-height:1.5em;font-size:1.5em;''') string(defaultValue: '', description: 'Credentials ID configured in Jenkins to access database.K8 cluster e.g k8credentials', name: 'DATABASEK8_CREDENTIALS_ID', trim: true) string(defaultValue: '', description: 'DriverURL to classaccess ofK8 databasecluster e.g com.microsoft.sqlserver.jdbc.SQLServerDriver. https://*******-dns-2ce021bb.hcp.eastus.azmk8s.io:443. You can get the server Url from K8 config file.', name: 'BACKEND_DB_DRIVER_CLASSSERVER_URL', trim: true) string(defaultValue: '', description: 'Database typeCluster context to access K8 cluster e.g. SQLadeptia-Servercontext', name: 'BACKENDCLUSTER_DB_TYPECONTEXT', trim: true) } agent { label 'LinuxAgent' } stages { stage('Pull XML from GitHub)') { steps { echo 'Checkout from GitHub' checkout([$class: 'GitSCM', branches: [[name: '*/'+GIT_BRANCH]], extensions: [], userRemoteConfigs: [[credentialsId: GIT_CREDENTIALS_ID, url: GIT_REPO_URL]]]) } } stage('Upload files to PVC') { steps { echo 'Uploading export xml file' uploadToSharedPVC (NAMESPACE, CLUSTER_CONTEXT, K8_CREDENTIALS_ID, SERVER_URL, GIT_EXPORT_XML_PATH, MIGRATION_XML_FILE_PATH) } } stage('Pull Helm chart & Deploy Migrationstring(defaultValue: '', description: 'K8 cluster name space deployment where Connect microservices deployed e.g. adeptia', name: 'NAMESPACE', trim: true) string(defaultValue: '', description: 'URL of database backend bind with application.', name: 'BACKEND_DB_URL', trim: true) string(defaultValue: '', description: 'Credentials ID configured in Jenkins to access database.', name: 'DATABASE_CREDENTIALS_ID', trim: true) string(defaultValue: '', description: 'Driver class of database e.g com.microsoft.sqlserver.jdbc.SQLServerDriver', name: 'BACKEND_DB_DRIVER_CLASS', trim: true) string(defaultValue: '', description: 'Database type e.g SQL-Server.', name: 'BACKEND_DB_TYPE', trim: true) } /* agent { label 'LinuxAgent' } */ agent any stages { stage('Pull XML from GitHub)') { steps { echo 'PullingCheckout Helmfrom ChartGitHub' pullHelmChart (HELM_REPO_URL, CHART_NAME) checkout([$class: 'GitSCM', branches: [[name: '*/'+GIT_BRANCH]], extensions: [], userRemoteConfigs: [[credentialsId: GIT_CREDENTIALS_ID, url: GIT_REPO_URL]]]) echo 'Deploying Helm Chart'} } deployToCluster (NAMESPACE, CLUSTER_CONTEXT, K8_CREDENTIALS_ID, DATABASE_CREDENTIALS_ID, SERVER_URL, EXPORT_ZIP_PATH, MIGRATION_XML_FILE_PATH) timeout(time: env.time_out, unit: "SECONDS"){stage('Upload files to PVC') { steps { echo 'Uploading export xml file' waitUntilDepoymentCompleteuploadToSharedPVC (NAMESPACE, CLUSTER_CONTEXT, K8_CREDENTIALS_ID, SERVER_URL, 'migration-', env.time_out.toInteger()) } } } stage('Download Zip from PVC') {GIT_EXPORT_XML_PATH, MIGRATION_XML_FILE_PATH) } } steps { downloadFromSharedPVC (NAMESPACE, CLUSTER_CONTEXT, K8_CREDENTIALS_ID, stage('Pull Helm chart & Deploy Migration') { steps { echo 'Pulling Helm Chart' pullHelmChart (HELM_REPO_URL, CHART_NAME) echo 'Deploying Helm Chart' deployToCluster (NAMESPACE, CLUSTER_CONTEXT, K8_CREDENTIALS_ID, DATABASE_CREDENTIALS_ID, SERVER_URL, EXPORT_ZIP_PATH, GITMIGRATION_EXPORTXML_ZIPFILE_PATH) } } stage('Push Zip to GitHub') { steps { pushToGitHub (GIT_BRANCH, GIT_CREDENTIALS_ID, GIT_REPO_URL, GIT_EXPORT_ZIP_PATH) } timeout(time: env.time_out, unit: "SECONDS"){ waitUntilDepoymentComplete(NAMESPACE, CLUSTER_CONTEXT, K8_CREDENTIALS_ID, SERVER_URL, 'migration-', env.time_out.toInteger()) } } } stage('Download Zip from PVC') { } } post('Clean-up') { always { echo 'Cleanup workspace' cleanWs() } success { echo 'Pipeline succeeded!' } unstable { echo 'Pipeline unstable :/' } failure { echo 'Pipeline failed :(' } } }
- Paste the copied content in the Pipeline Definition section in Jenkins.
- Uncheck the Use Groovy Sandbox checkbox.
- Click
steps { downloadFromSharedPVC (NAMESPACE, CLUSTER_CONTEXT, K8_CREDENTIALS_ID, SERVER_URL, EXPORT_ZIP_PATH, GIT_EXPORT_ZIP_PATH) } } stage('Push Zip to GitHub') { steps { pushToGitHub (GIT_BRANCH, GIT_CREDENTIALS_ID, GIT_REPO_URL, GIT_EXPORT_ZIP_PATH) } } } post('Clean-up') { always { echo 'Cleanup workspace' cleanWs() } success { echo 'Pipeline succeeded!' } unstable { echo 'Pipeline unstable :/' } failure { echo 'Pipeline failed :(' } } }
In the Pipeline Definition section, paste the copied content and uncheck the Use Groovy Sandbox checkbox.
Warning title Important If you are using Jenkins on Windows OS, and have created an agent on Linux OS, you need to do the followings in the export pipeline file.
1. Uncomment the following code snippet.
Code Block language css theme Midnight /* agent { label 'LinuxAgent' } */
Where,
LinuxAgent is the name of the agent that you have created.
2. Comment the following lines of code.
Code Block language css theme Midnight agent any
- Click Save.
On the screen that follows, click click Build Now.
As you build the pipeline for the very first time, all the parameters get initialized.Refresh the page.
The Build Now Now option now changes to Build with Parameters.Click Click Build with Parameters.
You will see all the parameters inherited from the export pipeline file.
Enter the parameter values as per your requirement.
Info It is mandatory to provide a valid value for all the Jenkins parameters. Expand title Click here to expand the list of Export parameters
prathi-Parameters Value Description Helm Chart
HELM_REPO_URL https://adeptia.github.io/adeptia-connect-migration/charts Migration Helm chart repository URL. CHART_NAME migration Migration Helm chart name. GitHub GIT_CREDENTIALS_ID <credential ID generated by Jenkins>
Credential ID for GitHub in Jenkins.
Refer to the prerequisites for more details.
GIT_REPO_URL https://github.com/ adeptia/migration-defination.git URL of the GitHub repository. GIT_BRANCH main GitHub branch name. GIT_EXPORT_XML_PATH xml/export.xml Path of the export XML in the GitHub repository. GIT_EXPORT_ZIP_PATH test/SA_PF.zip Path of the exported ZIP in the GitHub repository. Migration OPERATION export The type of operation for which deployment will be performed. MIGRATION_XML_FILE_PATH /shared/migrationtest1/export.xml Path of the export XML in the PVC. EXPORT_ZIP_PATH
/shared/migrationtest1/SA_PF.zip Path of the exported ZIP in the PVC. LOG_IDENTIFIER Test_Identifier_Tag Log identifier to capture logs from MS environment. Kubernetes Cluster K8_CREDENTIALS_ID <credential ID generated by Jenkins> Credential ID for Kubernetes in Jenkins.
Refer to the prerequisites for more details.
SERVER_URL https://<host name of the Kubernetes cluster>:<Port number> URL of the Kubernetes cluster. CLUSTER_CONTEXT test-dev Kubernetes cluster context. NAMESPACE namespace Kubernetes cluster namespace for deployment. Database BACKEND_DB_URL jdbc:sqlserver://<DB Hostname>:<Port number>;database=<Backend Database Name> Backend database URL used in the deployment of migration Helm chart. Database info configured in value.yaml file. DATABASE_CREDENTIALS_ID <credential ID generated by Jenkins> Credential ID for database in Jenkins.
Refer to the prerequisites for more details.
BACKEND_DB_DRIVER_CLASS com.microsoft.sqlserver.jdbc.SQLServerDriver Backend database driver class used in the deployment of migration Helm chart. Database info configured in values.yaml file. BACKEND_DB_TYPE SQL-Server Backend database type used in the deployment of migration Helm chart. Database info configured in values.yaml file. Click Click Build to to trigger the pipeline.
Info The exported ZIP is created and pushed to the GitHub repository.
All the log statements generated by the migration utility during the export process are tagged with a unique identifier. This allows you to search for this unique identifier in the centralized logging system, and fetch all the associated logs.