From 7b8df17602d859474963a2ba3b343f5d6503c50f Mon Sep 17 00:00:00 2001 From: Kumar Gauraw Date: Mon, 15 Apr 2024 17:38:56 +0530 Subject: [PATCH 1/2] Issue #IQ-750 fix: added script for inquiry upload schema --- pipelines/upload/schema/inquiry/Jenkinsfile | 55 +++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 pipelines/upload/schema/inquiry/Jenkinsfile diff --git a/pipelines/upload/schema/inquiry/Jenkinsfile b/pipelines/upload/schema/inquiry/Jenkinsfile new file mode 100644 index 0000000000..f37147a563 --- /dev/null +++ b/pipelines/upload/schema/inquiry/Jenkinsfile @@ -0,0 +1,55 @@ +@Library('deploy-conf') _ +node() { + try { + String ANSI_GREEN = "\u001B[32m" + String ANSI_NORMAL = "\u001B[0m" + String ANSI_BOLD = "\u001B[1m" + String ANSI_RED = "\u001B[31m" + String ANSI_YELLOW = "\u001B[33m" + + stage('checkout public repo') { + folder = new File("$WORKSPACE/.git") + if (folder.exists()) + { + println "Found .git folder. Clearing it.." + sh'git clean -fxd' + } + checkout scm + } + + ansiColor('xterm') { + values = [:] + currentWs = sh(returnStdout: true, script: 'pwd').trim() + envDir = sh(returnStdout: true, script: "echo $JOB_NAME").split('/')[-3].trim() + module = sh(returnStdout: true, script: "echo $JOB_NAME").split('/')[-2].trim() + jobName = sh(returnStdout: true, script: "echo $JOB_NAME").split('/')[-1].trim() + stage('deploy artifact'){ + sh """ + rm -rf schema_repo + git clone ${params.schema_repo} -b ${params.schema_repo_branch_or_tag} schema_repo + """ + ansiblePlaybook = "${currentWs}/ansible/kp_upload-schema.yml" + ansibleExtraArgs = "--extra-vars \" source_name=${currentWs}/schema_repo/schemas \" --vault-password-file /var/lib/jenkins/secrets/vault-pass" + values.put('currentWs', currentWs) + values.put('env', envDir) + values.put('module', module) + values.put('jobName', jobName) + values.put('ansiblePlaybook', ansiblePlaybook) + values.put('ansibleExtraArgs', ansibleExtraArgs) + println values + ansible_playbook_run(values) + currentBuild.result = 'SUCCESS' + currentBuild.description = "Private: ${params.private_branch}, Public: ${params.branch_or_tag}, schema_repo_branch_or_tag: ${params.schema_repo_branch_or_tag}" + } + } + summary() + } + catch (err) { + currentBuild.result = 'FAILURE' + throw err + } + finally { + slack_notify(currentBuild.result) + email_notify() + } +} From 6ba4a46fafa1acf589ff03610a9120aca7f536ab Mon Sep 17 00:00:00 2001 From: Kumar Gauraw Date: Wed, 17 Apr 2024 15:33:01 +0530 Subject: [PATCH 2/2] Issue #IQ-750 fix: updated jenkins script --- .../{ => jobs}/InquiryUploadSchema/config.xml | 86 +++++++------------ 1 file changed, 31 insertions(+), 55 deletions(-) rename deploy/jenkins/jobs/Deploy/jobs/dev/jobs/Kubernetes/{ => jobs}/InquiryUploadSchema/config.xml (68%) diff --git a/deploy/jenkins/jobs/Deploy/jobs/dev/jobs/Kubernetes/InquiryUploadSchema/config.xml b/deploy/jenkins/jobs/Deploy/jobs/dev/jobs/Kubernetes/jobs/InquiryUploadSchema/config.xml similarity index 68% rename from deploy/jenkins/jobs/Deploy/jobs/dev/jobs/Kubernetes/InquiryUploadSchema/config.xml rename to deploy/jenkins/jobs/Deploy/jobs/dev/jobs/Kubernetes/jobs/InquiryUploadSchema/config.xml index 7441f81065..1735ad1e56 100644 --- a/deploy/jenkins/jobs/Deploy/jobs/dev/jobs/Kubernetes/InquiryUploadSchema/config.xml +++ b/deploy/jenkins/jobs/Deploy/jobs/dev/jobs/Kubernetes/jobs/InquiryUploadSchema/config.xml @@ -1,8 +1,16 @@ - - + + + + + hudson.model.ParametersDefinitionProperty + com.sonyericsson.rebuild.RebuildSettings + + + false + -1 @@ -11,20 +19,21 @@ 5 - - + + false + + false false - + private_branch - choice-parameter-2544395024638227 1 true - + true @@ -44,13 +53,12 @@ return """<b>This parameter is not used</b>""" ET_FORMATTED_HTML true - + branch_or_tag - choice-parameter-2620434998790477 1 true - + true @@ -71,52 +79,20 @@ return """<b>This parameter is not used</b>""" ET_FORMATTED_HTML true - + schema_repo - <font color=dimgray size=2><b>Enter the repo url from which schema folder to be uploaded</b></font> - - - https://github.com/Sunbird-inQuiry/inquiry-api-service.git - https://github.com/project-sunbird/knowledge-platform.git - - - + Enter the repo url from which schema folder to be uploaded + https://github.com/Sunbird-inQuiry/inquiry-api-service.git + false + schema_repo_branch_or_tag - <font color=dimgray size=2><b>Enter the branch or tag for schema repo</b></font> - + Enter the branch or tag for schema repo false - - source_folder - - choice-parameter-5348290139923778 - 1 - - true - - - - InquiryUploadSchema - Deploy/dev/Kubernetes/InquiryUploadSchema - - - PT_MULTI_SELECT - false - 1 - - + 0 0 @@ -130,8 +106,8 @@ return """<b>This parameter is not used</b>""" - - + + 2 @@ -155,9 +131,9 @@ return """<b>This parameter is not used</b>""" - pipelines/upload/schema/knowledge-platform/schema.Jenkinsfile + pipelines/upload/schema/inquiry/Jenkinsfile false false - + \ No newline at end of file