From 80ea3ed2647d7db202d9a80abc919c66a4ac23a5 Mon Sep 17 00:00:00 2001 From: Yury-Fridlyand Date: Fri, 21 Oct 2022 16:07:51 -0700 Subject: [PATCH 1/4] Copy jenkinsfile from java repo. Signed-off-by: Yury-Fridlyand --- jenkins/stage-maven-release.jenkinsfile | 78 +++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 jenkins/stage-maven-release.jenkinsfile diff --git a/jenkins/stage-maven-release.jenkinsfile b/jenkins/stage-maven-release.jenkinsfile new file mode 100644 index 0000000000..19102693b0 --- /dev/null +++ b/jenkins/stage-maven-release.jenkinsfile @@ -0,0 +1,78 @@ +lib = library(identifier: 'jenkins@main', retriever: modernSCM([ + $class: 'GitSCMSource', + remote: 'https://github.com/opensearch-project/opensearch-build.git', +])) + +pipeline { + agent { + docker { + label 'Jenkins-Agent-AL2-X64-C54xlarge-Docker-Host' + image 'opensearchstaging/ci-runner:ci-runner-centos7-opensearch-build-v2' + args '-e JAVA_HOME=/opt/java/openjdk-11' + alwaysPull true + } + } + triggers { + GenericTrigger( + genericVariables: [ + [key: 'ref', value: '$.ref'], + [key: 'VERSION', value: '$.ref', regexpFilter: 'refs/tags/v' ], + ], + tokenCredentialId: 'jenkins-sql-generic-webhook-token', + causeString: 'A tag was cut on opensearch-project/sql repository causing this workflow to run', + printContributedVariables: false, + printPostContent: false, + regexpFilterText: '$ref', + regexpFilterExpression: '^refs/tags/.*' + ) + } + environment { + ARTIFACT_PATH = "$WORKSPACE/build/repository/org/opensearch/client/sql/$VERSION" + } + stages { + stage('Publish to Maven Local') { + steps { + // checkout the commit + checkout([ + $class: 'GitSCM', userRemoteConfigs: [[url: 'https://github.com/opensearch-project/sql.git']], + branches: [[name: "$ref"]] + ]) + + // publish maven artifacts + sh('./gradlew --no-daemon publishPublishMavenPublicationToLocalRepoRepository') + } + } + stage('Sign') { + steps { + script { + signArtifacts( + artifactPath: "${ARTIFACT_PATH}", + type: 'maven', + platform: 'linux' + ) + } + } + } + stage('Stage Maven Artifacts') { + environment { + REPO_URL = 'https://aws.oss.sonatype.org/' + STAGING_PROFILE_ID = "${SONATYPE_STAGING_PROFILE_ID}" + BUILD_ID = "${BUILD_NUMBER}" + } + steps { + // checkout the build repo + git url: 'https://github.com/opensearch-project/opensearch-build.git', branch: 'main' + + // stage artifacts for release with Sonatype + withCredentials([usernamePassword(credentialsId: 'jenkins-sonatype-creds', usernameVariable: 'SONATYPE_USERNAME', passwordVariable: 'SONATYPE_PASSWORD')]) { + sh('$WORKSPACE/publish/stage-maven-release.sh $WORKSPACE/build/repository/') + } + } + } + } + post { + always { + cleanWs disableDeferredWipeout: true, deleteDirs: true + } + } +} From 62ad714342d9f383a91ba05a164f7257d47668e8 Mon Sep 17 00:00:00 2001 From: Yury-Fridlyand Date: Fri, 21 Oct 2022 17:31:26 -0700 Subject: [PATCH 2/4] Update scripts. Signed-off-by: Yury-Fridlyand --- ...le => jdbc-stage-maven-release.jenkinsfile} | 6 ++++-- sql-jdbc/build.gradle | 18 ++++-------------- 2 files changed, 8 insertions(+), 16 deletions(-) rename jenkins/{stage-maven-release.jenkinsfile => jdbc-stage-maven-release.jenkinsfile} (93%) diff --git a/jenkins/stage-maven-release.jenkinsfile b/jenkins/jdbc-stage-maven-release.jenkinsfile similarity index 93% rename from jenkins/stage-maven-release.jenkinsfile rename to jenkins/jdbc-stage-maven-release.jenkinsfile index 19102693b0..774544120a 100644 --- a/jenkins/stage-maven-release.jenkinsfile +++ b/jenkins/jdbc-stage-maven-release.jenkinsfile @@ -38,8 +38,10 @@ pipeline { branches: [[name: "$ref"]] ]) - // publish maven artifacts - sh('./gradlew --no-daemon publishPublishMavenPublicationToLocalRepoRepository') + dir('sql-jdbc') { + // publish maven artifacts + sh('./gradlew --no-daemon publishShadowPublicationToLocalRepoRepository') + } } } stage('Sign') { diff --git a/sql-jdbc/build.gradle b/sql-jdbc/build.gradle index 7b3cc71317..7ec56ba2c7 100644 --- a/sql-jdbc/build.gradle +++ b/sql-jdbc/build.gradle @@ -147,20 +147,6 @@ publishing { } repositories { - maven { - name = "internal-snapshots" - url = "s3://snapshots.opendistroforelasticsearch.amazon.com/maven" - authentication { - awsIm(AwsImAuthentication) // load from EC2 role or env var - } - } - maven { - name = "internal-releases" - url = "s3://artifacts.opendistroforelasticsearch.amazon.com/maven" - authentication { - awsIm(AwsImAuthentication) // load from EC2 role or env var - } - } maven { name = "sonatype-staging" url "https://aws.oss.sonatype.org/service/local/staging/deploy/maven2" @@ -169,6 +155,10 @@ publishing { password project.hasProperty('ossrhPassword') ? project.property('ossrhPassword') : '' } } + maven { + name = "localRepo" + url "${project.buildDir}/repository" + } } // TODO - enabled debug logging for the time being, remove this eventually From dcacde3a49af052a9c87dbfaddee0a074c9f96f3 Mon Sep 17 00:00:00 2001 From: Yury-Fridlyand Date: Mon, 24 Oct 2022 11:27:42 -0700 Subject: [PATCH 3/4] Add non-shadow publishing. Signed-off-by: Yury-Fridlyand --- jenkins/jdbc-stage-maven-release.jenkinsfile | 2 +- sql-jdbc/build.gradle | 66 ++++++++++++++------ 2 files changed, 47 insertions(+), 21 deletions(-) diff --git a/jenkins/jdbc-stage-maven-release.jenkinsfile b/jenkins/jdbc-stage-maven-release.jenkinsfile index 774544120a..eb090a672b 100644 --- a/jenkins/jdbc-stage-maven-release.jenkinsfile +++ b/jenkins/jdbc-stage-maven-release.jenkinsfile @@ -40,7 +40,7 @@ pipeline { dir('sql-jdbc') { // publish maven artifacts - sh('./gradlew --no-daemon publishShadowPublicationToLocalRepoRepository') + sh('./gradlew --no-daemon publishPublishMavenPublicationToLocalRepoRepository') } } } diff --git a/sql-jdbc/build.gradle b/sql-jdbc/build.gradle index 7ec56ba2c7..bf8e876980 100644 --- a/sql-jdbc/build.gradle +++ b/sql-jdbc/build.gradle @@ -120,28 +120,54 @@ publishing { artifact javadocJar pom { - name = "OpenSearch SQL JDBC Driver" - packaging = "jar" - url = "https://github.com/opensearch-project/sql" - description = "OpenSearch SQL JDBC driver" - scm { - connection = "scm:git@github.com:opensearch-project/sql.git" - developerConnection = "scm:git@github.com:opensearch-project/sql.git" - url = "git@github.com:opensearch-project/sql.git" - } - licenses { - license { - name = "The Apache License, Version 2.0" - url = "http://www.apache.org/licenses/LICENSE-2.0.txt" + name = "OpenSearch SQL JDBC Driver" + packaging = "jar" + url = "https://github.com/opensearch-project/sql/sql-jdbc" + description = "OpenSearch SQL JDBC driver" + scm { + connection = "scm:git@github.com:opensearch-project/sql.git" + developerConnection = "scm:git@github.com:opensearch-project/sql.git" + url = "git@github.com:opensearch-project/sql.git" } - } - developers { - developer { - id = "amazonwebservices" - organization = "Amazon Web Services" - organizationUrl = "https://aws.amazon.com" + licenses { + license { + name = "The Apache License, Version 2.0" + url = "http://www.apache.org/licenses/LICENSE-2.0.txt" + } + } + developers { + developer { + name = 'OpenSearch' + url = 'https://github.com/opensearch-project/sql' + } + } + } + } + publishMaven(MavenPublication) { publication -> + from components.java + + pom { + name = "OpenSearch SQL JDBC Driver" + packaging = "jar" + url = "https://github.com/opensearch-project/sql/sql-jdbc" + description = "OpenSearch SQL JDBC driver" + scm { + connection = "scm:git@github.com:opensearch-project/sql.git" + developerConnection = "scm:git@github.com:opensearch-project/sql.git" + url = "git@github.com:opensearch-project/sql.git" + } + licenses { + license { + name = "The Apache License, Version 2.0" + url = "http://www.apache.org/licenses/LICENSE-2.0.txt" + } + } + developers { + developer { + name = 'OpenSearch' + url = 'https://github.com/opensearch-project/sql' + } } - } } } } From 6b7f5f14bb6905d10e479b98fc48f865ef18f4e3 Mon Sep 17 00:00:00 2001 From: Yury-Fridlyand Date: Mon, 24 Oct 2022 12:13:34 -0700 Subject: [PATCH 4/4] Remove obsolete references. Signed-off-by: Yury-Fridlyand --- sql-jdbc/build.gradle | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/sql-jdbc/build.gradle b/sql-jdbc/build.gradle index bf8e876980..08554d5e66 100644 --- a/sql-jdbc/build.gradle +++ b/sql-jdbc/build.gradle @@ -69,7 +69,7 @@ tasks.withType(JavaCompile) { } static def getShadowPath(String path) { - return 'com.amazonaws.opensearch.sql.jdbc.shadow.' + path + return 'org.opensearch.sql.jdbc.shadow.' + path } shadowJar { @@ -87,10 +87,7 @@ shadowJar { exclude 'META-INF/NOTICE*' exclude 'META-INF/DEPENDENCIES' - relocate('com.amazonaws', getShadowPath('com.amazonaws')) { - exclude 'com.amazonaws.opensearch.*/**' - } - + relocate 'com.amazonaws', getShadowPath('com.amazonaws') relocate 'org.apache', getShadowPath('org.apache') relocate 'org.joda', getShadowPath('org.joda') relocate 'com.fasterxml', getShadowPath('com.fasterxml')