From 0721e8523d57657b9dc66caebb4f7212b71a1c38 Mon Sep 17 00:00:00 2001 From: Divya Madala <113469545+Divyaasm@users.noreply.github.com> Date: Mon, 11 Mar 2024 11:15:21 -0700 Subject: [PATCH] Add implementation to get component names from Input manifest (#393) Signed-off-by: Divya Madala --- build.gradle | 2 +- src/jenkins/InputManifest.groovy | 36 +++++++++++++++++++ tests/jenkins/jobs/InputManifest_Jenkinsfile | 4 +++ .../jobs/InputManifest_Jenkinsfile.txt | 6 ++++ 4 files changed, 47 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 3ec17a80e..e2df6c87a 100644 --- a/build.gradle +++ b/build.gradle @@ -121,7 +121,7 @@ jacocoTestReport { } } -String version = '6.3.2' +String version = '6.3.3' task updateVersion { doLast { diff --git a/src/jenkins/InputManifest.groovy b/src/jenkins/InputManifest.groovy index 3e86f15a8..d3715899d 100644 --- a/src/jenkins/InputManifest.groovy +++ b/src/jenkins/InputManifest.groovy @@ -53,12 +53,37 @@ class InputManifest { } } + class Components extends HashMap { + + Components(ArrayList data) { + data.each { item -> + Component component = new Component(item) + this[component.name] = component + } + } + } + + class Component implements Serializable { + String name + String ref + String repository + + Component(Map data) { + this.name = data.name + this.ref = data.ref + this.repository = data.repository + } + + } + Build build Ci ci + Components components InputManifest(Map data) { this.build = new InputManifest.Build(data.build) this.ci = data.ci ? new InputManifest.Ci(data.ci) : null + this.components = new InputManifest.Components(data.components) } String getSHAsRoot(String jobName) { @@ -68,4 +93,15 @@ class InputManifest { 'shas' ].join("/") } + + public ArrayList getNames() { + def componentsName = [] + this.components.each { key, value -> componentsName.add(key) } + return componentsName + } + + public String getRepo(String name) { + return this.components.get(name).repository + } + } diff --git a/tests/jenkins/jobs/InputManifest_Jenkinsfile b/tests/jenkins/jobs/InputManifest_Jenkinsfile index fdbb84f9b..ff23cc5a3 100644 --- a/tests/jenkins/jobs/InputManifest_Jenkinsfile +++ b/tests/jenkins/jobs/InputManifest_Jenkinsfile @@ -34,6 +34,10 @@ pipeline { echo inputManifest.build.version echo inputManifest.build.getFilename() echo inputManifest.getSHAsRoot('bundle-build') + def componentNames = inputManifest.getNames() + echo componentNames.join(', ') + echo inputManifest.getRepo('OpenSearch') + echo inputManifest.getRepo('dashboards-reports') } } } diff --git a/tests/jenkins/jobs/InputManifest_Jenkinsfile.txt b/tests/jenkins/jobs/InputManifest_Jenkinsfile.txt index 056c26c70..2a71c7748 100644 --- a/tests/jenkins/jobs/InputManifest_Jenkinsfile.txt +++ b/tests/jenkins/jobs/InputManifest_Jenkinsfile.txt @@ -23,3 +23,9 @@ InputManifest_Jenkinsfile.echo(opensearch) InputManifest.getSHAsRoot(bundle-build) InputManifest_Jenkinsfile.echo(bundle-build/1.2.0/shas) + InputManifest.getNames() + InputManifest_Jenkinsfile.echo(index-management, job-scheduler, anomaly-detection, performance-analyzer, common-utils, cross-cluster-replication, asynchronous-search, OpenSearch, alerting, sql, security, k-NN, dashboards-reports, opensearch-observability) + InputManifest.getRepo(OpenSearch) + InputManifest_Jenkinsfile.echo(https://github.com/opensearch-project/OpenSearch.git) + InputManifest.getRepo(dashboards-reports) + InputManifest_Jenkinsfile.echo(https://github.com/opensearch-project/dashboards-reports.git)