-
Notifications
You must be signed in to change notification settings - Fork 370
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3992 from krgauraw/release-8.0.0
Issue #IQ-750 fix: added script for inquiry upload schema
- Loading branch information
Showing
2 changed files
with
86 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
|
@@ -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 """<input name="value" value="${private_repo_branch}" class="setting-input" type="text"><br> <font color=dimgray size=2><b>Change this value to checkout a different branch from private repository.</b></font>""" | ||
} | ||
else | ||
return """<b>This parameter is not used</b>"""</script> | ||
<sandbox>true</sandbox> | ||
</secureScript> | ||
<secureFallbackScript plugin="script-security@1.76"> | ||
<secureFallbackScript plugin="script-security@1138.v8e727069a_025"> | ||
<script>return """<b>This parameter is not used</b>"""</script> | ||
<sandbox>true</sandbox> | ||
</secureFallbackScript> | ||
|
@@ -44,13 +53,12 @@ return """<b>This parameter is not used</b>"""</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 """<input name="value" value="" class="setting-input" type="text"><br> <font color=dimgray size=2><b>Provide the tag or branch name to checkout the Jenkinsfile and codebase.<br>Note: The tag or branch name for this job should be taken from <a href="https://github.com/project-sunbird/sunbird-devops">project-sunbird/sunbird-devops</a></b></font></b></font>"""; | ||
|
||
|
@@ -59,7 +67,7 @@ else | |
return """<b>This parameter is not used</b>"""</script> | ||
<sandbox>true</sandbox> | ||
</secureScript> | ||
<secureFallbackScript plugin="script-security@1.76"> | ||
<secureFallbackScript plugin="script-security@1138.v8e727069a_025"> | ||
<script>return """<b>This parameter is not used</b>"""</script> | ||
<sandbox>true</sandbox> | ||
</secureFallbackScript> | ||
|
@@ -71,52 +79,20 @@ return """<b>This parameter is not used</b>"""</script> | |
<choiceType>ET_FORMATTED_HTML</choiceType> | ||
<omitValueField>true</omitValueField> | ||
</org.biouno.unochoice.DynamicReferenceParameter> | ||
<hudson.model.ChoiceParameterDefinition> | ||
<hudson.model.StringParameterDefinition> | ||
<name>schema_repo</name> | ||
<description><font color=dimgray size=2><b>Enter the repo url from which schema folder to be uploaded</b></font></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><font color=dimgray size=2><b>Enter the branch or tag for schema repo</b></font></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"/> | ||
|
@@ -130,8 +106,8 @@ return """<b>This parameter is not used</b>"""</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> | ||
|
@@ -155,9 +131,9 @@ return """<b>This parameter is not used</b>"""</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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} | ||
} |