Skip to content

Commit

Permalink
Merge pull request #3992 from krgauraw/release-8.0.0
Browse files Browse the repository at this point in the history
Issue #IQ-750 fix: added script for inquiry upload schema
  • Loading branch information
santhosh-tg authored Apr 17, 2024
2 parents e8fd7d1 + 6ba4a46 commit 361d2ba
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 55 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?><flow-definition plugin="[email protected]">
<actions/>
<?xml version="1.1" encoding="UTF-8" standalone="no"?><flow-definition plugin="[email protected]">
<actions>
<org.jenkinsci.plugins.workflow.multibranch.JobPropertyTrackerAction plugin="[email protected]_e52371b_">
<jobPropertyDescriptors>
<string>hudson.model.ParametersDefinitionProperty</string>
<string>com.sonyericsson.rebuild.RebuildSettings</string>
</jobPropertyDescriptors>
</org.jenkinsci.plugins.workflow.multibranch.JobPropertyTrackerAction>
</actions>
<description/>
<keepDependencies>false</keepDependencies>
<properties>
<hudson.plugins.jira.JiraProjectProperty plugin="[email protected]"/>
<jenkins.model.BuildDiscarderProperty>
<strategy class="hudson.tasks.LogRotator">
<daysToKeep>-1</daysToKeep>
Expand All @@ -11,28 +19,29 @@
<artifactNumToKeep>5</artifactNumToKeep>
</strategy>
</jenkins.model.BuildDiscarderProperty>
<org.jenkinsci.plugins.workflow.job.properties.DisableConcurrentBuildsJobProperty/>
<com.sonyericsson.rebuild.RebuildSettings plugin="[email protected]">
<org.jenkinsci.plugins.workflow.job.properties.DisableConcurrentBuildsJobProperty>
<abortPrevious>false</abortPrevious>
</org.jenkinsci.plugins.workflow.job.properties.DisableConcurrentBuildsJobProperty>
<com.sonyericsson.rebuild.RebuildSettings plugin="[email protected]">
<autoRebuild>false</autoRebuild>
<rebuildDisabled>false</rebuildDisabled>
</com.sonyericsson.rebuild.RebuildSettings>
<hudson.model.ParametersDefinitionProperty>
<parameterDefinitions>
<org.biouno.unochoice.DynamicReferenceParameter plugin="uno-choice@2.5.6">
<org.biouno.unochoice.DynamicReferenceParameter plugin="uno-choice@2.6.1">
<name>private_branch</name>
<description/>
<randomName>choice-parameter-2544395024638227</randomName>
<visibleItemCount>1</visibleItemCount>
<script class="org.biouno.unochoice.model.GroovyScript">
<secureScript plugin="script-security@1.76">
<secureScript plugin="script-security@1138.v8e727069a_025">
<script>if (override_private_branch.equals("true")) {
return """&lt;input name="value" value="${private_repo_branch}" class="setting-input" type="text"&gt;&lt;br&gt; &lt;font color=dimgray size=2&gt;&lt;b&gt;Change this value to checkout a different branch from private repository.&lt;/b&gt;&lt;/font&gt;"""
}
else
return """&lt;b&gt;This parameter is not used&lt;/b&gt;"""</script>
<sandbox>true</sandbox>
</secureScript>
<secureFallbackScript plugin="script-security@1.76">
<secureFallbackScript plugin="script-security@1138.v8e727069a_025">
<script>return """&lt;b&gt;This parameter is not used&lt;/b&gt;"""</script>
<sandbox>true</sandbox>
</secureFallbackScript>
Expand All @@ -44,13 +53,12 @@ return """&lt;b&gt;This parameter is not used&lt;/b&gt;"""</script>
<choiceType>ET_FORMATTED_HTML</choiceType>
<omitValueField>true</omitValueField>
</org.biouno.unochoice.DynamicReferenceParameter>
<org.biouno.unochoice.DynamicReferenceParameter plugin="uno-choice@2.5.6">
<org.biouno.unochoice.DynamicReferenceParameter plugin="uno-choice@2.6.1">
<name>branch_or_tag</name>
<description/>
<randomName>choice-parameter-2620434998790477</randomName>
<visibleItemCount>1</visibleItemCount>
<script class="org.biouno.unochoice.model.GroovyScript">
<secureScript plugin="script-security@1.76">
<secureScript plugin="script-security@1138.v8e727069a_025">
<script>if (override_public_branch.equals("true")) {
return """&lt;input name="value" value="" class="setting-input" type="text"&gt;&lt;br&gt; &lt;font color=dimgray size=2&gt;&lt;b&gt;Provide the tag or branch name to checkout the Jenkinsfile and codebase.&lt;br&gt;Note: The tag or branch name for this job should be taken from &lt;a href="https://github.com/project-sunbird/sunbird-devops"&gt;project-sunbird/sunbird-devops&lt;/a&gt;&lt;/b&gt;&lt;/font&gt;&lt;/b&gt;&lt;/font&gt;""";

Expand All @@ -59,7 +67,7 @@ else
return """&lt;b&gt;This parameter is not used&lt;/b&gt;"""</script>
<sandbox>true</sandbox>
</secureScript>
<secureFallbackScript plugin="script-security@1.76">
<secureFallbackScript plugin="script-security@1138.v8e727069a_025">
<script>return """&lt;b&gt;This parameter is not used&lt;/b&gt;"""</script>
<sandbox>true</sandbox>
</secureFallbackScript>
Expand All @@ -71,52 +79,20 @@ return """&lt;b&gt;This parameter is not used&lt;/b&gt;"""</script>
<choiceType>ET_FORMATTED_HTML</choiceType>
<omitValueField>true</omitValueField>
</org.biouno.unochoice.DynamicReferenceParameter>
<hudson.model.ChoiceParameterDefinition>
<hudson.model.StringParameterDefinition>
<name>schema_repo</name>
<description>&lt;font color=dimgray size=2&gt;&lt;b&gt;Enter the repo url from which schema folder to be uploaded&lt;/b&gt;&lt;/font&gt;</description>
<choices class="java.util.Arrays$ArrayList">
<a class="string-array">
<string>https://github.com/Sunbird-inQuiry/inquiry-api-service.git</string>
<string>https://github.com/project-sunbird/knowledge-platform.git</string>
</a>
</choices>
</hudson.model.ChoiceParameterDefinition>
<description>Enter the repo url from which schema folder to be uploaded</description>
<defaultValue>https://github.com/Sunbird-inQuiry/inquiry-api-service.git</defaultValue>
<trim>false</trim>
</hudson.model.StringParameterDefinition>
<hudson.model.StringParameterDefinition>
<name>schema_repo_branch_or_tag</name>
<description>&lt;font color=dimgray size=2&gt;&lt;b&gt;Enter the branch or tag for schema repo&lt;/b&gt;&lt;/font&gt;</description>
<defaultValue/>
<description>Enter the branch or tag for schema repo</description>
<trim>false</trim>
</hudson.model.StringParameterDefinition>
<org.biouno.unochoice.CascadeChoiceParameter plugin="[email protected]">
<name>source_folder</name>
<description/>
<randomName>choice-parameter-5348290139923778</randomName>
<visibleItemCount>1</visibleItemCount>
<script class="org.biouno.unochoice.model.GroovyScript">
<secureScript plugin="[email protected]">
<script>return ['assessmentitem',
'category',
'question',
'questionset',
'objectcategory']</script>
<sandbox>true</sandbox>
</secureScript>
<secureFallbackScript plugin="[email protected]">
<script/>
<sandbox>true</sandbox>
</secureFallbackScript>
</script>
<projectName>InquiryUploadSchema</projectName>
<projectFullName>Deploy/dev/Kubernetes/InquiryUploadSchema</projectFullName>
<parameters class="linked-hash-map"/>
<referencedParameters/>
<choiceType>PT_MULTI_SELECT</choiceType>
<filterable>false</filterable>
<filterLength>1</filterLength>
</org.biouno.unochoice.CascadeChoiceParameter>
</parameterDefinitions>
</hudson.model.ParametersDefinitionProperty>
<hudson.plugins.throttleconcurrents.ThrottleJobProperty plugin="throttle-concurrents@2.2">
<hudson.plugins.throttleconcurrents.ThrottleJobProperty plugin="throttle-concurrents@2.10">
<maxConcurrentPerNode>0</maxConcurrentPerNode>
<maxConcurrentTotal>0</maxConcurrentTotal>
<categories class="java.util.concurrent.CopyOnWriteArrayList"/>
Expand All @@ -130,8 +106,8 @@ return """&lt;b&gt;This parameter is not used&lt;/b&gt;"""</script>
<triggers/>
</org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty>
</properties>
<definition class="org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition" plugin="workflow-cps@2.90">
<scm class="hudson.plugins.git.GitSCM" plugin="git@4.7.1">
<definition class="org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition" plugin="workflow-cps@2660.2664.v4c114e93f4c1">
<scm class="hudson.plugins.git.GitSCM" plugin="git@4.11.5">
<configVersion>2</configVersion>
<userRemoteConfigs>
<hudson.plugins.git.UserRemoteConfig>
Expand All @@ -155,9 +131,9 @@ return """&lt;b&gt;This parameter is not used&lt;/b&gt;"""</script>
</hudson.plugins.git.extensions.impl.CloneOption>
</extensions>
</scm>
<scriptPath>pipelines/upload/schema/knowledge-platform/schema.Jenkinsfile</scriptPath>
<scriptPath>pipelines/upload/schema/inquiry/Jenkinsfile</scriptPath>
<lightweight>false</lightweight>
</definition>
<triggers/>
<disabled>false</disabled>
</flow-definition>
</flow-definition>
55 changes: 55 additions & 0 deletions pipelines/upload/schema/inquiry/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -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()
}
}

0 comments on commit 361d2ba

Please sign in to comment.