Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add JDBC driver jenkins CI workflow #957

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions jenkins/jdbc-stage-maven-release.jenkinsfile
Original file line number Diff line number Diff line change
@@ -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
}
}
peterzhuamazon marked this conversation as resolved.
Show resolved Hide resolved
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"
Copy link
Member

@peterzhuamazon peterzhuamazon Oct 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We used to put the jdbc in this location during ODFE.
Probably we want to keep similar subfolder structure?

https://repo1.maven.org/maven2/com/amazon/opendistroforelasticsearch/client/opendistro-sql-jdbc/

Thanks.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is the path where gradle places compiled jar:

$ tree build | grep -v class
build
....
├── repository
│   └── org
│       └── opensearch
│           └── driver
│               └── opensearch-sql-jdbc
│                   ├── 2.0.0.0
│                   │   ├── opensearch-sql-jdbc-2.0.0.0.jar
....

In general, there is the same structure, but we renamed

  • com.amazon to org.opensearch
  • opendistroforelasticsearch and opendistro to opensearch
  • client to driver

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I revert this?

}
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')
}
}
}
Comment on lines +45 to +58
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will need to discuss a bit as we want two options: triggered by tag or manually trigger on Jenkins.
Just in case there is issues with github and we can still release.
See maps server jenkinsfile for more references:
https://github.com/peterzhuamazon/maps/blob/a40788a611e1d0f573d715e0b1ce59b7fb33e4d0/jenkins/maps-server-release.jenkinsfile

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/')
peterzhuamazon marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
}
post {
always {
cleanWs disableDeferredWipeout: true, deleteDirs: true
}
}
}
93 changes: 53 additions & 40 deletions sql-jdbc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,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'
Expand Down Expand Up @@ -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 {
Expand All @@ -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')
Expand Down Expand Up @@ -120,47 +117,59 @@ 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:[email protected]:opensearch-project/sql.git"
developerConnection = "scm:[email protected]:opensearch-project/sql.git"
url = "[email protected]: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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should move to opensearch-project/sql-jdbc

description = "OpenSearch SQL JDBC driver"
scm {
connection = "scm:[email protected]:opensearch-project/sql.git"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should move to opensearch-project/sql-jdbc.git

developerConnection = "scm:[email protected]:opensearch-project/sql.git"
url = "[email protected]:opensearch-project/sql.git"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should move to opensearch-project/sql-jdbc.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'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should move to opensearch-project/sql-jdbc.git

}
}
}
}
}
}
publishMaven(MavenPublication) { publication ->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the group of the jdbc?
org.opensearch.client.opensearch-sql-jdbc

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, org.opensearch.client. What should be?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Yury-Fridlyand and @peterzhuamazon should this be org.opensearch.driver as groupId? and artifact name should be opensearch-sql-jdbc.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 79deba0.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my next comment on this.

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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should move to opensearch-project/sql-jdbc

description = "OpenSearch SQL JDBC driver"
scm {
connection = "scm:[email protected]:opensearch-project/sql.git"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should move to opensearch-project/sql-jdbc.git

developerConnection = "scm:[email protected]:opensearch-project/sql.git"
url = "[email protected]:opensearch-project/sql.git"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should move to opensearch-project/sql-jdbc.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'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should move to opensearch-project/sql-jdbc

}
}
}
}
}

repositories {
maven {
name = "sonatype-staging"
url "https://aws.oss.sonatype.org/service/local/staging/deploy/maven2"
Expand All @@ -169,6 +178,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
Expand Down