Skip to content

Commit

Permalink
Add a new product parameter to include tag creation for both OpenSear… (
Browse files Browse the repository at this point in the history
opensearch-project#1773)

* Add a new product parameter to include tag creation for both OpenSearch & OpenSearch Dashboards

Signed-off-by: Zelin Hao <[email protected]>

* Rename the parameter to distribution manifest and add tests for dashboards

Signed-off-by: Zelin Hao <[email protected]>
  • Loading branch information
zelinh authored Mar 17, 2022
1 parent da4a6d3 commit c5bfd3f
Show file tree
Hide file tree
Showing 9 changed files with 170 additions and 20 deletions.
15 changes: 10 additions & 5 deletions jenkins/release-tag/release-tag.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,24 @@ pipeline {
description: 'Version of the release.',
trim: true
)
choice(
choices: ['opensearch', 'opensearch-dashboards'],
name: 'PRODUCT',
description: 'Product for tag creation.'
)
}
environment {
BUILD_MANIFEST = "opensearch-$VERSION/manifest.yml"
DISTRIBUTION_MANIFEST = "$PRODUCT-$VERSION/manifest.yml"
}
stages {
stage('Create Release Tag') {
steps {
script {
release_url = "https://artifacts.opensearch.org/releases/bundle/opensearch/$VERSION/opensearch-$VERSION-linux-x64.tar.gz"
sh "curl -SLO $release_url && tar -xf opensearch-$VERSION-linux-x64.tar.gz opensearch-$VERSION/manifest.yml"
echo "The release distribution manifest is downloaded to $BUILD_MANIFEST"
release_url = "https://artifacts.opensearch.org/releases/bundle/$PRODUCT/$VERSION/$PRODUCT-$VERSION-linux-x64.tar.gz"
sh "curl -SLO $release_url && tar -xf $PRODUCT-$VERSION-linux-x64.tar.gz $PRODUCT-$VERSION/manifest.yml"
echo "The release distribution manifest is downloaded to $DISTRIBUTION_MANIFEST"
createReleaseTag(
buildManifest: "$BUILD_MANIFEST",
distManifest: "$DISTRIBUTION_MANIFEST",
tagVersion: VERSION
)

Expand Down
34 changes: 34 additions & 0 deletions tests/jenkins/TestReleaseTagDashboardsJob.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/


import jenkins.tests.BuildPipelineTest
import org.junit.Before
import org.junit.Test

class TestReleaseTagDashboardsJob extends BuildPipelineTest {

@Before
void setUp() {

def distManifest = 'tests/data/opensearch-dashboards-build-1.2.0.yml'

this.registerLibTester(new CreateReleaseTagLibTester(distManifest, '1.2.0'))

super.setUp()

// Variables for Release Tag Job
binding.setVariable('VERSION', '1.2.0')
binding.setVariable('PRODUCT', 'opensearch-dashboards')
binding.setVariable('DISTRIBUTION_MANIFEST', distManifest)

}

@Test
void ReleaseTagDashboards_test() {
super.testPipeline('jenkins/release-tag/release-tag.jenkinsfile',
'tests/jenkins/jenkinsjob-regression-files/release-tag/release-tag-dashboards.jenkinsfile')
}
}
7 changes: 4 additions & 3 deletions tests/jenkins/TestReleaseTagJob.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@ class TestReleaseTagJob extends BuildPipelineTest {
@Before
void setUp() {

def buildManifest = 'tests/data/opensearch-build-1.1.0.yml'
def distManifest = 'tests/data/opensearch-build-1.1.0.yml'

this.registerLibTester(new CreateReleaseTagLibTester(buildManifest, '1.1.0'))
this.registerLibTester(new CreateReleaseTagLibTester(distManifest, '1.1.0'))

super.setUp()

// Variables for Release Tag Job
binding.setVariable('VERSION', '1.1.0')
binding.setVariable('BUILD_MANIFEST', buildManifest)
binding.setVariable('PRODUCT', 'opensearch')
binding.setVariable('DISTRIBUTION_MANIFEST', distManifest)

}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
release-tag.run()
release-tag.legacySCM(groovy.lang.Closure)
release-tag.library({identifier=jenkins@20211123, retriever=null})
release-tag.pipeline(groovy.lang.Closure)
release-tag.timeout({time=2, unit=HOURS})
release-tag.echo(Executing on agent [docker:[image:opensearchstaging/ci-runner:centos7-x64-arm64-jdkmulti-node10.24.1-cypress6.9.1-20211130, reuseNode:false, stages:[:], args:, alwaysPull:true, containerPerStageRoot:false, label:Jenkins-Agent-al2-x64-c54xlarge-Docker-Host]])
release-tag.stage(Create Release Tag, groovy.lang.Closure)
release-tag.script(groovy.lang.Closure)
release-tag.sh(curl -SLO https://artifacts.opensearch.org/releases/bundle/opensearch-dashboards/1.2.0/opensearch-dashboards-1.2.0-linux-x64.tar.gz && tar -xf opensearch-dashboards-1.2.0-linux-x64.tar.gz opensearch-dashboards-1.2.0/manifest.yml)
release-tag.echo(The release distribution manifest is downloaded to tests/data/opensearch-dashboards-build-1.2.0.yml)
release-tag.createReleaseTag({distManifest=tests/data/opensearch-dashboards-build-1.2.0.yml, tagVersion=1.2.0})
createReleaseTag.legacySCM(groovy.lang.Closure)
createReleaseTag.library({identifier=jenkins@20211123, retriever=null})
createReleaseTag.readYaml({file=tests/data/opensearch-dashboards-build-1.2.0.yml})
BuildManifest.asBoolean()
BuildManifest.getNames()
createReleaseTag.echo(Creating 1.2.0 release tag for 10 components in the manifest)
createReleaseTag.usernamePassword({credentialsId=dummy_token_name, usernameVariable=GITHUB_USER, passwordVariable=GITHUB_TOKEN})
createReleaseTag.withCredentials([[GITHUB_USER, GITHUB_TOKEN]], groovy.lang.Closure)
BuildManifest.getCommitId(ganttChartDashboards)
BuildManifest.getRepo(ganttChartDashboards)
createReleaseTag.echo(Tagging ganttChartDashboards at 2123bc65873e026cb8b0fd26816a6b1980bd19ce ...)
createReleaseTag.dir(ganttChartDashboards, groovy.lang.Closure)
createReleaseTag.checkout({$class=GitSCM, branches=[{name=2123bc65873e026cb8b0fd26816a6b1980bd19ce}], userRemoteConfigs=[{url=https://github.com/opensearch-project/dashboards-visualizations.git}]})
createReleaseTag.sh({script=git ls-remote --tags https://github.com/opensearch-project/dashboards-visualizations.git 1.2.0.0 | awk 'NR==1{print $1}', returnStdout=true})
createReleaseTag.echo(Tag 1.2.0.0 has been created with identical commit ID. Skipping creating new tag for ganttChartDashboards.)
BuildManifest.getCommitId(indexManagementDashboards)
BuildManifest.getRepo(indexManagementDashboards)
createReleaseTag.echo(Tagging indexManagementDashboards at 6748b18ee172138b4811a459053f4a43c1486821 ...)
createReleaseTag.dir(indexManagementDashboards, groovy.lang.Closure)
createReleaseTag.checkout({$class=GitSCM, branches=[{name=6748b18ee172138b4811a459053f4a43c1486821}], userRemoteConfigs=[{url=https://github.com/opensearch-project/index-management-dashboards-plugin}]})
createReleaseTag.sh({script=git ls-remote --tags https://github.com/opensearch-project/index-management-dashboards-plugin 1.2.0.0 | awk 'NR==1{print $1}', returnStdout=true})
createReleaseTag.echo(Creating 1.2.0.0 tag for indexManagementDashboards)
createReleaseTag.sh(git tag 1.2.0.0)
createReleaseTag.sh(git push https://[email protected]/opensearch-project/index-management-dashboards-plugin 1.2.0.0)
BuildManifest.getCommitId(anomalyDetectionDashboards)
BuildManifest.getRepo(anomalyDetectionDashboards)
createReleaseTag.echo(Tagging anomalyDetectionDashboards at c4921f4471aeab38db80eb47cd92b4f7a3e04126 ...)
createReleaseTag.dir(anomalyDetectionDashboards, groovy.lang.Closure)
createReleaseTag.checkout({$class=GitSCM, branches=[{name=c4921f4471aeab38db80eb47cd92b4f7a3e04126}], userRemoteConfigs=[{url=https://github.com/opensearch-project/anomaly-detection-dashboards-plugin}]})
createReleaseTag.sh({script=git ls-remote --tags https://github.com/opensearch-project/anomaly-detection-dashboards-plugin 1.2.0.0 | awk 'NR==1{print $1}', returnStdout=true})
createReleaseTag.echo(Creating 1.2.0.0 tag for anomalyDetectionDashboards)
createReleaseTag.sh(git tag 1.2.0.0)
createReleaseTag.sh(git push https://[email protected]/opensearch-project/anomaly-detection-dashboards-plugin 1.2.0.0)
BuildManifest.getCommitId(OpenSearch-Dashboards)
BuildManifest.getRepo(OpenSearch-Dashboards)
createReleaseTag.echo(Tagging OpenSearch-Dashboards at caf668e73304bac890f41c37cd6c3a41257cd289 ...)
createReleaseTag.dir(OpenSearch-Dashboards, groovy.lang.Closure)
createReleaseTag.checkout({$class=GitSCM, branches=[{name=caf668e73304bac890f41c37cd6c3a41257cd289}], userRemoteConfigs=[{url=https://github.com/opensearch-project/OpenSearch-Dashboards.git}]})
createReleaseTag.sh({script=git ls-remote --tags https://github.com/opensearch-project/OpenSearch-Dashboards.git 1.2.0 | awk 'NR==1{print $1}', returnStdout=true})
createReleaseTag.echo(Creating 1.2.0 tag for OpenSearch-Dashboards)
createReleaseTag.sh(git tag 1.2.0)
createReleaseTag.sh(git push https://[email protected]/opensearch-project/OpenSearch-Dashboards.git 1.2.0)
BuildManifest.getCommitId(securityDashboards)
BuildManifest.getRepo(securityDashboards)
createReleaseTag.echo(Tagging securityDashboards at 960ef753f74dceb793e8936a40ac8c6cbec88dd1 ...)
createReleaseTag.dir(securityDashboards, groovy.lang.Closure)
createReleaseTag.checkout({$class=GitSCM, branches=[{name=960ef753f74dceb793e8936a40ac8c6cbec88dd1}], userRemoteConfigs=[{url=https://github.com/opensearch-project/security-dashboards-plugin.git}]})
createReleaseTag.sh({script=git ls-remote --tags https://github.com/opensearch-project/security-dashboards-plugin.git 1.2.0.0 | awk 'NR==1{print $1}', returnStdout=true})
createReleaseTag.echo(Creating 1.2.0.0 tag for securityDashboards)
createReleaseTag.sh(git tag 1.2.0.0)
createReleaseTag.sh(git push https://[email protected]/opensearch-project/security-dashboards-plugin.git 1.2.0.0)
BuildManifest.getCommitId(functionalTestDashboards)
BuildManifest.getRepo(functionalTestDashboards)
createReleaseTag.echo(Tagging functionalTestDashboards at 208227256bf6dece2976da528bf41bae56e4effc ...)
createReleaseTag.dir(functionalTestDashboards, groovy.lang.Closure)
createReleaseTag.checkout({$class=GitSCM, branches=[{name=208227256bf6dece2976da528bf41bae56e4effc}], userRemoteConfigs=[{url=https://github.com/opensearch-project/opensearch-dashboards-functional-test.git}]})
createReleaseTag.sh({script=git ls-remote --tags https://github.com/opensearch-project/opensearch-dashboards-functional-test.git 1.2.0.0 | awk 'NR==1{print $1}', returnStdout=true})
createReleaseTag.echo(Creating 1.2.0.0 tag for functionalTestDashboards)
createReleaseTag.sh(git tag 1.2.0.0)
createReleaseTag.sh(git push https://[email protected]/opensearch-project/opensearch-dashboards-functional-test.git 1.2.0.0)
BuildManifest.getCommitId(alertingDashboards)
BuildManifest.getRepo(alertingDashboards)
createReleaseTag.echo(Tagging alertingDashboards at 07d4cb8bc9c62b15bf7cb4fd4e3fc3a818f9152d ...)
createReleaseTag.dir(alertingDashboards, groovy.lang.Closure)
createReleaseTag.checkout({$class=GitSCM, branches=[{name=07d4cb8bc9c62b15bf7cb4fd4e3fc3a818f9152d}], userRemoteConfigs=[{url=https://github.com/opensearch-project/alerting-dashboards-plugin}]})
createReleaseTag.sh({script=git ls-remote --tags https://github.com/opensearch-project/alerting-dashboards-plugin 1.2.0.0 | awk 'NR==1{print $1}', returnStdout=true})
createReleaseTag.echo(Creating 1.2.0.0 tag for alertingDashboards)
createReleaseTag.sh(git tag 1.2.0.0)
createReleaseTag.sh(git push https://[email protected]/opensearch-project/alerting-dashboards-plugin 1.2.0.0)
BuildManifest.getCommitId(queryWorkbenchDashboards)
BuildManifest.getRepo(queryWorkbenchDashboards)
createReleaseTag.echo(Tagging queryWorkbenchDashboards at a675eac2ed32a228184c47c289cfd22fde479139 ...)
createReleaseTag.dir(queryWorkbenchDashboards, groovy.lang.Closure)
createReleaseTag.checkout({$class=GitSCM, branches=[{name=a675eac2ed32a228184c47c289cfd22fde479139}], userRemoteConfigs=[{url=https://github.com/opensearch-project/sql.git}]})
createReleaseTag.sh({script=git ls-remote --tags https://github.com/opensearch-project/sql.git 1.2.0.0 | awk 'NR==1{print $1}', returnStdout=true})
createReleaseTag.echo(Creating 1.2.0.0 tag for queryWorkbenchDashboards)
createReleaseTag.sh(git tag 1.2.0.0)
createReleaseTag.sh(git push https://[email protected]/opensearch-project/sql.git 1.2.0.0)
BuildManifest.getCommitId(reportsDashboards)
BuildManifest.getRepo(reportsDashboards)
createReleaseTag.echo(Tagging reportsDashboards at 290523a6d825c9c073818aebfcbe4813cb2554bc ...)
createReleaseTag.dir(reportsDashboards, groovy.lang.Closure)
createReleaseTag.checkout({$class=GitSCM, branches=[{name=290523a6d825c9c073818aebfcbe4813cb2554bc}], userRemoteConfigs=[{url=https://github.com/opensearch-project/dashboards-reports.git}]})
createReleaseTag.sh({script=git ls-remote --tags https://github.com/opensearch-project/dashboards-reports.git 1.2.0.0 | awk 'NR==1{print $1}', returnStdout=true})
createReleaseTag.echo(Creating 1.2.0.0 tag for reportsDashboards)
createReleaseTag.sh(git tag 1.2.0.0)
createReleaseTag.sh(git push https://[email protected]/opensearch-project/dashboards-reports.git 1.2.0.0)
BuildManifest.getCommitId(observabilityDashboards)
BuildManifest.getRepo(observabilityDashboards)
createReleaseTag.echo(Tagging observabilityDashboards at 4fde4040c0a43233b41a862a169e2bd1616f6b1b ...)
createReleaseTag.dir(observabilityDashboards, groovy.lang.Closure)
createReleaseTag.checkout({$class=GitSCM, branches=[{name=4fde4040c0a43233b41a862a169e2bd1616f6b1b}], userRemoteConfigs=[{url=https://github.com/opensearch-project/trace-analytics.git}]})
createReleaseTag.sh({script=git ls-remote --tags https://github.com/opensearch-project/trace-analytics.git 1.2.0.0 | awk 'NR==1{print $1}', returnStdout=true})
createReleaseTag.echo(Creating 1.2.0.0 tag for observabilityDashboards)
createReleaseTag.sh(git tag 1.2.0.0)
createReleaseTag.sh(git push https://[email protected]/opensearch-project/trace-analytics.git 1.2.0.0)
release-tag.script(groovy.lang.Closure)
release-tag.postCleanup()
postCleanup.cleanWs({disableDeferredWipeout=true, deleteDirs=true})
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
release-tag.script(groovy.lang.Closure)
release-tag.sh(curl -SLO https://artifacts.opensearch.org/releases/bundle/opensearch/1.1.0/opensearch-1.1.0-linux-x64.tar.gz && tar -xf opensearch-1.1.0-linux-x64.tar.gz opensearch-1.1.0/manifest.yml)
release-tag.echo(The release distribution manifest is downloaded to tests/data/opensearch-build-1.1.0.yml)
release-tag.createReleaseTag({buildManifest=tests/data/opensearch-build-1.1.0.yml, tagVersion=1.1.0})
release-tag.createReleaseTag({distManifest=tests/data/opensearch-build-1.1.0.yml, tagVersion=1.1.0})
createReleaseTag.legacySCM(groovy.lang.Closure)
createReleaseTag.library({identifier=jenkins@20211123, retriever=null})
createReleaseTag.readYaml({file=tests/data/opensearch-build-1.1.0.yml})
Expand Down
2 changes: 1 addition & 1 deletion tests/jenkins/jobs/CreateReleaseTag_Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pipeline {
steps {
script {
createReleaseTag(
buildManifest: "tests/data/opensearch-build-1.1.0.yml",
distManifest: "tests/data/opensearch-build-1.1.0.yml",
tagVersion: "1.1.0"
)
}
Expand Down
2 changes: 1 addition & 1 deletion tests/jenkins/jobs/CreateReleaseTag_Jenkinsfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
CreateReleaseTag_Jenkinsfile.echo(Executing on agent [label:none])
CreateReleaseTag_Jenkinsfile.stage(createTag, groovy.lang.Closure)
CreateReleaseTag_Jenkinsfile.script(groovy.lang.Closure)
CreateReleaseTag_Jenkinsfile.createReleaseTag({buildManifest=tests/data/opensearch-build-1.1.0.yml, tagVersion=1.1.0})
CreateReleaseTag_Jenkinsfile.createReleaseTag({distManifest=tests/data/opensearch-build-1.1.0.yml, tagVersion=1.1.0})
createReleaseTag.legacySCM(groovy.lang.Closure)
createReleaseTag.library({identifier=jenkins@20211123, retriever=null})
createReleaseTag.readYaml({file=tests/data/opensearch-build-1.1.0.yml})
Expand Down
14 changes: 7 additions & 7 deletions tests/jenkins/lib-testers/CreateReleaseTagLibTester.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@ import static org.hamcrest.MatcherAssert.assertThat

class CreateReleaseTagLibTester extends LibFunctionTester {

private String buildManifest
private String distManifest
private String tagVersion
private ArrayList buildManifestComponentsList

public CreateReleaseTagLibTester(buildManifest, tagVersion){
this.buildManifest = buildManifest
public CreateReleaseTagLibTester(distManifest, tagVersion){
this.distManifest = distManifest
this.tagVersion = tagVersion
this.buildManifestComponentsList = []
}

void parameterInvariantsAssertions(call){
assertThat(call.args.buildManifest.first(), notNullValue())
assertThat(call.args.distManifest.first(), notNullValue())
assertThat(call.args.tagVersion.first(), notNullValue())
}

boolean expectedParametersMatcher(call) {
return call.args.buildManifest.first().toString().equals(this.buildManifest)
return call.args.distManifest.first().toString().equals(this.distManifest)
&& call.args.tagVersion.first().toString().equals(this.tagVersion)
&& this.buildManifestComponentsList.size() > 1
}
Expand All @@ -39,7 +39,7 @@ class CreateReleaseTagLibTester extends LibFunctionTester {

helper.registerAllowedMethod("checkout", [Map], {})
helper.registerAllowedMethod("dir", [Map], {})
InputStream inputStream = new FileInputStream(new File(this.buildManifest));
InputStream inputStream = new FileInputStream(new File(this.distManifest));
Yaml yaml = new Yaml()
Map ymlMap = yaml.load(inputStream)
BuildManifest buildManifestObj = new BuildManifest(ymlMap)
Expand All @@ -48,7 +48,7 @@ class CreateReleaseTagLibTester extends LibFunctionTester {
for (component in this.buildManifestComponentsList) {
def repo = buildManifestObj.getRepo(component)
def version = "$tagVersion.0"
if (component == "OpenSearch") {
if (component == "OpenSearch" || component == "OpenSearch-Dashboards") {
version = tagVersion
}
def out = ""
Expand Down
Loading

0 comments on commit c5bfd3f

Please sign in to comment.