From b55748a1de41188781d7b7b3d73935cbfa7259f8 Mon Sep 17 00:00:00 2001 From: Sayali Gaikawad <61760125+gaiksaya@users.noreply.github.com> Date: Sat, 14 Jan 2023 10:05:50 -0800 Subject: [PATCH 1/2] Add workflow to publish snapshots via GHA (#325) * Add workflow to publish snapshots via GHA Signed-off-by: Sayali Gaikawad * Fix task name Signed-off-by: Sayali Gaikawad * Fix conflict and add documentation Signed-off-by: Sayali Gaikawad Signed-off-by: Sayali Gaikawad Signed-off-by: Vacha Shah --- README.md | 5 ++- java-client/build.gradle.kts | 7 ++-- jenkins/publish-snapshot.jenkinsfile | 50 ---------------------------- 3 files changed, 9 insertions(+), 53 deletions(-) delete mode 100644 jenkins/publish-snapshot.jenkinsfile diff --git a/README.md b/README.md index 6b2638a067..06ec9c85cd 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Please see the [USER_GUIDE](USER_GUIDE.md) for code snippets. * [Documentation](https://opensearch.org/docs/latest/clients/java/) * [JavaDoc](https://www.javadoc.io/doc/org.opensearch.client/opensearch-java/latest/index.html) * [Maven Central](https://search.maven.org/artifact/org.opensearch.client/opensearch-java) -* [Snapshot Builds](https://aws.oss.sonatype.org/content/repositories/snapshots/org/opensearch/client/opensearch-java/) +* [Snapshot Builds](#snapshot-builds) * Need help? Try [Forums](https://discuss.opendistrocommunity.dev/) * [Project Principles](https://opensearch.org/#principles) * [Contributing to OpenSearch](CONTRIBUTING.md) @@ -52,6 +52,9 @@ This project has adopted the [Amazon Open Source Code of Conduct](CODE_OF_CONDUC See [User Guide](USER_GUIDE.md). +## Snapshot Builds +The [snapshots builds](https://aws.oss.sonatype.org/content/repositories/snapshots/org/opensearch/client/opensearch-java/) are published to sonatype using [publish-snapshots.yml](./.github/workflows/publish-snapshots.yml) workflow. Each `push` event to the main branch triggers this workflow. + ## Compatibility with OpenSearch See [Compatibility](COMPATIBILITY.md). diff --git a/java-client/build.gradle.kts b/java-client/build.gradle.kts index 7f482efd60..463e7b0f18 100644 --- a/java-client/build.gradle.kts +++ b/java-client/build.gradle.kts @@ -260,8 +260,11 @@ publishing { repositories{ if (version.toString().endsWith("SNAPSHOT")) { maven("https://aws.oss.sonatype.org/content/repositories/snapshots/") { - name = "snapshotRepo" - credentials(PasswordCredentials::class) + name = "Snapshots" + credentials { + username = System.getenv("SONATYPE_USERNAME") + password = System.getenv("SONATYPE_PASSWORD") + } } } maven("${rootProject.buildDir}/repository") { diff --git a/jenkins/publish-snapshot.jenkinsfile b/jenkins/publish-snapshot.jenkinsfile deleted file mode 100644 index 73ffdce604..0000000000 --- a/jenkins/publish-snapshot.jenkinsfile +++ /dev/null @@ -1,50 +0,0 @@ -pipeline { - options { - timeout(time: 30, unit: 'MINUTES') - throttleJobProperty( - categories: [], - limitOneJobWithMatchingParams: false, - maxConcurrentPerNode: 0, - maxConcurrentTotal: 1, - paramsToUseForLimit: '', - throttleEnabled: true, - throttleOption: 'project', - ) - } - 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'], - ], - tokenCredentialId: 'jenkins-opensearch-java-generic-webhook-token', - causeString: 'A commit was pushed on opensearch-project/opensearch-java repository main branch causing this workflow to run', - printContributedVariables: false, - printPostContent: false, - regexpFilterText: '$ref', - regexpFilterExpression: '^(refs/heads/main)$' - ) - } - stages { - stage('Publish to Sonatype Snapshots Repo') { - steps { - git url: 'https://github.com/opensearch-project/opensearch-java.git', branch: 'main' - withCredentials([usernamePassword(credentialsId: 'jenkins-sonatype-creds', usernameVariable: 'ORG_GRADLE_PROJECT_snapshotRepoUsername', passwordVariable: 'ORG_GRADLE_PROJECT_snapshotRepoPassword')]) { - sh './gradlew --no-daemon publishPublishMavenPublicationToSnapshotRepoRepository' - } - } - post { - always { - cleanWs disableDeferredWipeout: true, deleteDirs: true - } - } - } - } -} From 9681916fe471f6b0a42a9546ff64dfa91a21680d Mon Sep 17 00:00:00 2001 From: Vacha Shah Date: Fri, 14 Apr 2023 19:00:53 +0000 Subject: [PATCH 2/2] Fixing documentation for snapshot builds Signed-off-by: Vacha Shah --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 06ec9c85cd..1c73fe5a95 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ OpenSearch Java Client - [Project Resources](#project-resources) - [Code of Conduct](#code-of-conduct) - [User Guide](#user-guide) +- [Snapshot Builds](#snapshot-builds) - [Compatibility with OpenSearch](#compatibility-with-opensearch) - [Security](#security) - [License](#license) @@ -53,7 +54,7 @@ This project has adopted the [Amazon Open Source Code of Conduct](CODE_OF_CONDUC See [User Guide](USER_GUIDE.md). ## Snapshot Builds -The [snapshots builds](https://aws.oss.sonatype.org/content/repositories/snapshots/org/opensearch/client/opensearch-java/) are published to sonatype using [publish-snapshots.yml](./.github/workflows/publish-snapshots.yml) workflow. Each `push` event to the main branch triggers this workflow. +The [snapshots builds](https://aws.oss.sonatype.org/content/repositories/snapshots/org/opensearch/client/opensearch-java/) are published to sonatype using [publish-snapshots.yml](./.github/workflows/publish-snapshots.yml) workflow. ## Compatibility with OpenSearch