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

Jenkins workflows to release -SNAPSHOT builds and to stage releases in maven #187

Merged
merged 3 commits into from
Jul 28, 2022

Conversation

dblock
Copy link
Member

@dblock dblock commented Jul 28, 2022

Description

On top of #186, build locally without maven local, sign, then release to maven staging.

We're misusing publishToMavenLocal, that takes a publishable set of artifacts, then actually publishes it to local maven (~/.m2). Then we try to get files from there and make them publishable again (by renaming maven-metadata-local for example). All that is too much work.

With this PR you can do ./gradlew --no-daemon publishPublishMavenPublicationToSnapshotRepoRepository for -SNAPSHOT builds, and VERSION=2.1.0 ./gradlew --no-daemon publishPublishMavenPublicationToLocalRepoRepository for producing local output that can be signed and uploaded to staging .

This just uploads -SNAPSHOTs.

ORG_GRADLE_PROJECT_snapshotsUsername=... ORG_GRADLE_PROJECT_snapshotsPassword=... ./gradlew publishPublishMavenPublicationToSnapshotRepoRepository

This produces local output which can then be uploaded to staging.

VERSION=2.1.0 ./gradlew --no-daemon publishPublishMavenPublicationToLocalRepoRepository

$ ls -la ./build/repository/org/opensearch/client/opensearch-java/2.1.0/
total 38136
drwxr-xr-x  27 dblock  staff       864 Jul 28 14:42 .
drwxr-xr-x   8 dblock  staff       256 Jul 28 14:42 ..
-rw-r--r--   1 dblock  staff  11518615 Jul 28 14:42 opensearch-java-2.1.0-javadoc.jar
-rw-r--r--   1 dblock  staff        32 Jul 28 14:42 opensearch-java-2.1.0-javadoc.jar.md5
-rw-r--r--   1 dblock  staff        40 Jul 28 14:42 opensearch-java-2.1.0-javadoc.jar.sha1
-rw-r--r--   1 dblock  staff        64 Jul 28 14:42 opensearch-java-2.1.0-javadoc.jar.sha256
-rw-r--r--   1 dblock  staff       128 Jul 28 14:42 opensearch-java-2.1.0-javadoc.jar.sha512
-rw-r--r--   1 dblock  staff   2941649 Jul 28 14:42 opensearch-java-2.1.0-sources.jar
-rw-r--r--   1 dblock  staff        32 Jul 28 14:42 opensearch-java-2.1.0-sources.jar.md5
-rw-r--r--   1 dblock  staff        40 Jul 28 14:42 opensearch-java-2.1.0-sources.jar.sha1
-rw-r--r--   1 dblock  staff        64 Jul 28 14:42 opensearch-java-2.1.0-sources.jar.sha256
-rw-r--r--   1 dblock  staff       128 Jul 28 14:42 opensearch-java-2.1.0-sources.jar.sha512
-rw-r--r--   1 dblock  staff   4964269 Jul 28 14:42 opensearch-java-2.1.0.jar
-rw-r--r--   1 dblock  staff        32 Jul 28 14:42 opensearch-java-2.1.0.jar.md5
-rw-r--r--   1 dblock  staff        40 Jul 28 14:42 opensearch-java-2.1.0.jar.sha1
-rw-r--r--   1 dblock  staff        64 Jul 28 14:42 opensearch-java-2.1.0.jar.sha256
-rw-r--r--   1 dblock  staff       128 Jul 28 14:42 opensearch-java-2.1.0.jar.sha512
-rw-r--r--   1 dblock  staff      7796 Jul 28 14:42 opensearch-java-2.1.0.module
-rw-r--r--   1 dblock  staff        32 Jul 28 14:42 opensearch-java-2.1.0.module.md5
-rw-r--r--   1 dblock  staff        40 Jul 28 14:42 opensearch-java-2.1.0.module.sha1
-rw-r--r--   1 dblock  staff        64 Jul 28 14:42 opensearch-java-2.1.0.module.sha256
-rw-r--r--   1 dblock  staff       128 Jul 28 14:42 opensearch-java-2.1.0.module.sha512
-rw-r--r--   1 dblock  staff      3530 Jul 28 14:42 opensearch-java-2.1.0.pom
-rw-r--r--   1 dblock  staff        32 Jul 28 14:42 opensearch-java-2.1.0.pom.md5
-rw-r--r--   1 dblock  staff        40 Jul 28 14:42 opensearch-java-2.1.0.pom.sha1
-rw-r--r--   1 dblock  staff        64 Jul 28 14:42 opensearch-java-2.1.0.pom.sha256
-rw-r--r--   1 dblock  staff       128 Jul 28 14:42 opensearch-java-2.1.0.pom.sha512

The JenkinsFile was renamed to jenkins/stage-maven-release.jenkinsfile to be consistent.

See http://jenki-jenki-fpgmrv2ryxko-1366042710.us-east-1.elb.amazonaws.com/job/dblock-opensearch-java-stage-maven-release/4/console for a run that succeeded all the way till uploading to sonatype that requires SONATYPE_USERNAME and SONATYPE_PASSWORD that I believe aren't available in staging (or shouldn't be :)).

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: dblock <dblock@amazon.com>
@dblock dblock changed the title Release to maven. Simplify Jenkins workflow to release to maven staging Jul 28, 2022
@dblock dblock marked this pull request as ready for review July 28, 2022 17:17
@dblock dblock requested review from a team and madhusudhankonda as code owners July 28, 2022 17:17
Signed-off-by: dblock <dblock@amazon.com>
@dblock dblock changed the title Simplify Jenkins workflow to release to maven staging Jenkins workflows to release -SNAPSHOT builds and to stage releases in maven Jul 28, 2022
@dblock dblock mentioned this pull request Jul 28, 2022
jenkins/publish-snapshot.jenkinsfile Outdated Show resolved Hide resolved
jenkins/stage-maven-release.jenkinsfile Outdated Show resolved Hide resolved
jenkins/stage-maven-release.jenkinsfile Outdated Show resolved Hide resolved
jenkins/stage-maven-release.jenkinsfile Show resolved Hide resolved
jenkins/stage-maven-release.jenkinsfile Show resolved Hide resolved
@gaiksaya
Copy link
Member

for a run that succeeded all the way till uploading to sonatype that requires SONATYPE_USERNAME and SONATYPE_PASSWORD that I believe aren't available in staging (or shouldn't be :)).

We do have it in staging as even though it is successful, a manual intervention is required (as of today) to actually publish the snapshots to maven central.

@dblock
Copy link
Member Author

dblock commented Jul 28, 2022

Updated.

@dblock dblock requested a review from gaiksaya July 28, 2022 18:55
}
}
stages {
stage('Publish to Maven Staging') {
Copy link
Member

Choose a reason for hiding this comment

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

Rename to Publish to sonatype snapshots repo or something similar. Quite confusing as maven staging is actually a maven central staging area

jenkins/stage-maven-release.jenkinsfile Show resolved Hide resolved
error('Missing REF and/or VERSION.')
}
}
}
Copy link
Member

Choose a reason for hiding this comment

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

do you want to add triggers now or I can create a follow up PR. I have the code ready. Needs few PRs to add creds to jenkins infrastructure.

Copy link
Member Author

Choose a reason for hiding this comment

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

Let's do a followup.

script {
signArtifacts(
artifactPath: "${ARTIFACT_PATH}",
type: 'maven',
Copy link
Member

Choose a reason for hiding this comment

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

My bad. Please do type: 'maven',

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep. That's what I figured.

Signed-off-by: dblock <dblock@amazon.com>
@dblock
Copy link
Member Author

dblock commented Jul 28, 2022

More updates, thx. Let me know if you need anything else.

Copy link
Member

@gaiksaya gaiksaya left a comment

Choose a reason for hiding this comment

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

LGTM!

Comment on lines +44 to +46
// checkout the commit
git url: 'https://github.com/opensearch-project/opensearch-java.git', branch: 'main'
sh('git checkout ${REF}')
Copy link
Member

Choose a reason for hiding this comment

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

nit: Can be

                checkout([$class: 'GitSCM', userRemoteConfigs: [[url: 'https://github.com/gaiksaya/opensearch-java.git']],
                        branches: [[name: "$ref"]]])

@dblock
Copy link
Member Author

dblock commented Jul 28, 2022

@VachaShah care to +1? Thx

Copy link
Collaborator

@VachaShah VachaShah left a comment

Choose a reason for hiding this comment

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

Thank you @dblock!

It might be helpful to also add the details about the release and snapshot workflow in https://github.com/opensearch-project/opensearch-java/blob/main/RELEASING.md may be?

if (version.toString().endsWith("SNAPSHOT")) {
maven("https://aws.oss.sonatype.org/content/repositories/snapshots/") {
name = "snapshotRepo"
credentials(PasswordCredentials::class)
Copy link
Member

Choose a reason for hiding this comment

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

For my learning, how are these creds passed?

Copy link
Member Author

Choose a reason for hiding this comment

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

See above, this asks for a specific environment variable that gets set by the wrapper.

@@ -0,0 +1,25 @@
pipeline {
Copy link
Member

Choose a reason for hiding this comment

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

How does the Jenkins fleet pick this job/pipeline ?
Is there a corresponding file in opensearch-ci?

Also I see for every component, jenkins files are defined in opensearch-build. Why is this different?

Copy link
Member Author

Choose a reason for hiding this comment

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

@gaiksaya @peterzhuamazon ?

i think the job needs to be added manually once, but I could be wrong (I hope so)

Copy link
Member Author

Choose a reason for hiding this comment

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

We could move these to OpenSearch-build, I have no strong preference, I was replacing a file that was already here

Copy link
Member

Choose a reason for hiding this comment

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

Yeah for now we to manually added files, for releasing opensearch-java it already exists. @saratvemulapalli we are planning to move respective jenkins file for clients in their repo. Would be easier to manage. However, need to add regression tests for all jenkins file to see the behavior is as expected.

Copy link
Member

Choose a reason for hiding this comment

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

thanks that helps :).
One concern having these files in individual repositories is that the responsibility is delegated to the maintainers of the individual projects and make sure the infrastructure is not mis-used.

Copy link
Member

@gaiksaya gaiksaya Jul 28, 2022

Choose a reason for hiding this comment

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

I believe the maintenance of these files will be delegated to respective maintainers of the project rather than @opensearch-project/engineering-effectiveness being the bottle neck for it. Regarding the mis-use of the infrastructure, we have to be careful what triggers the workflows. For example, if a commit push is gonna trigger the workflow no matter where the workflow lies it will be executed.

@dblock dblock merged commit df34831 into opensearch-project:main Jul 28, 2022
@dblock
Copy link
Member Author

dblock commented Jul 28, 2022

Thank you @dblock!

It might be helpful to also add the details about the release and snapshot workflow in https://github.com/opensearch-project/opensearch-java/blob/main/RELEASING.md may be?

Absolutely. @gaiksaya plans to hook this up as a GHA that kicks off this job in Jenkins, and we will need to document how to make the release then

(This workflow is in Jenkins because we don’t export credentials Into GHA)

@gaiksaya
Copy link
Member

gaiksaya commented Jul 28, 2022

Actually @dblock , GHA is not in the picture as of now. Was experimenting and we can directly make a release using tags or pushes.
Will create a followup PR and add details then.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants