From 2531bc221e70daef656bc2d691801d2cc7cb68c7 Mon Sep 17 00:00:00 2001 From: Yury-Fridlyand Date: Thu, 8 Dec 2022 19:50:20 -0800 Subject: [PATCH] Copy changes from opensearch-project/sql#957. Signed-off-by: Yury-Fridlyand --- build.gradle | 93 +++++++++++--------- jenkins/jdbc-stage-maven-release.jenkinsfile | 92 +++++++++++++++++++ 2 files changed, 145 insertions(+), 40 deletions(-) create mode 100644 jenkins/jdbc-stage-maven-release.jenkinsfile diff --git a/build.gradle b/build.gradle index efa4979..dba2ea8 100644 --- a/build.gradle +++ b/build.gradle @@ -22,7 +22,7 @@ plugins { id 'signing' } -group 'org.opensearch.client' +group 'org.opensearch.driver' // keep version in sync with version in Driver source version '2.0.0.0' @@ -89,7 +89,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 { @@ -107,10 +107,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') @@ -139,47 +136,59 @@ publishing { artifact javadocJar pom { - name = "OpenSearch SQL JDBC Driver" - packaging = "jar" - url = "https://github.com/opensearch-project/sql-jdbc" - description = "OpenSearch SQL JDBC driver" - scm { - connection = "scm:git@github.com:opensearch-project/sql-jdbc.git" - developerConnection = "scm:git@github.com:opensearch-project/sql-jdbc.git" - url = "git@github.com:opensearch-project/sql-jdbc.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" + } + licenses { + license { + name = "The Apache License, Version 2.0" + url = "http://www.apache.org/licenses/LICENSE-2.0.txt" + } } - } - developers { - developer { - id = "amazonwebservices" - organization = "Amazon Web Services" - organizationUrl = "https://aws.amazon.com" + developers { + developer { + name = 'OpenSearch' + url = 'https://github.com/opensearch-project/sql' + } } - } } } - } + publishMaven(MavenPublication) { publication -> + from components.java - 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 + 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' + } + } } } + } + + repositories { maven { name = "sonatype-staging" url "https://aws.oss.sonatype.org/service/local/staging/deploy/maven2" @@ -188,6 +197,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 diff --git a/jenkins/jdbc-stage-maven-release.jenkinsfile b/jenkins/jdbc-stage-maven-release.jenkinsfile new file mode 100644 index 0000000..2b0d6c0 --- /dev/null +++ b/jenkins/jdbc-stage-maven-release.jenkinsfile @@ -0,0 +1,92 @@ +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 + } + } + options { + timeout(time: 30, unit: 'MINUTES') + throttleJobProperty( + categories: [], + limitOneJobWithMatchingParams: false, + maxConcurrentPerNode: 0, + maxConcurrentTotal: 1, + paramsToUseForLimit: '', + throttleEnabled: true, + throttleOption: 'project', + ) + } + triggers { + GenericTrigger( + genericVariables: [ + [key: 'ref', value: '$.ref'], + [key: 'VERSION', value: '$.ref', regexpFilter: 'refs/tags/v' ], + ], + tokenCredentialId: 'jenkins-sql-jdbc-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: '^sql-jdbc-release-[0-9\.]*$' + ) + } + environment { + ARTIFACT_PATH = "$WORKSPACE/build/repository/org/opensearch/driver/opensearch-sql-jdbc/$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"]] + ]) + + dir('sql-jdbc') { + // 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 + } + } +}