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

Jenkinsfile update for Gradle Check Publish Optimization #4719

Merged
merged 1 commit into from
May 22, 2024
Merged
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
32 changes: 22 additions & 10 deletions jenkins/gradle/gradle-check.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* compatible open source license.
*/

lib = library(identifier: '[email protected].6', retriever: modernSCM([
lib = library(identifier: '[email protected].7', retriever: modernSCM([
$class: 'GitSCMSource',
remote: 'https://github.com/opensearch-project/opensearch-build-libraries.git',
]))
Expand Down Expand Up @@ -60,7 +60,9 @@ pipeline {
[key: 'pr_from_clone_url', value: '$.pr_from_clone_url'],
[key: 'pr_to_clone_url', value: '$.pr_to_clone_url'],
[key: 'pr_title', value: '$.pr_title'],
[key: 'pr_number', value: '$.pr_number']
[key: 'pr_number', value: '$.pr_number'],
[key: 'post_merge_action', value: '$.post_merge_action'],
[key: 'pr_owner', value: '$.pr_owner']
],
tokenCredentialId: 'jenkins-gradle-check-generic-webhook-token',
causeString: 'Triggered by PR on OpenSearch core repository',
Expand Down Expand Up @@ -111,7 +113,7 @@ pipeline {
if (!env.BUILD_CAUSE.contains('Started by user') && !env.BUILD_CAUSE.contains('Started by timer')) {
def pr_url = "${pr_to_clone_url}".replace(".git", "/pull/${pr_number}")
println("Triggered by GitHub: ${pr_to_clone_url}")
if ("$pr_number" == "Null") {
if ("$post_merge_action" == "true") {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

With this change https://github.com/opensearch-project/OpenSearch/pull/13786/files the pr_number is not null anymore. A new field post_merge_action with true/false is added to identify the push event.

currentBuild.description = """runner: ${agent_name}<br><a href="${pr_to_clone_url}">Others</a>: ${pr_title}"""
}
else {
Expand Down Expand Up @@ -150,28 +152,38 @@ pipeline {
def invokedBy
def pullRequest
def pullRequestTitle
def gitReference
def pullRequestOwner
switch (true) {
case env.BUILD_CAUSE.contains('Started by user'):
invokedBy = 'User'
pullRequest = "${GIT_REFERENCE}"
pullRequestTitle = "Null"
pullRequest = "null"
pullRequestTitle = "null"
gitReference = "${GIT_REFERENCE}"
pullRequestOwner = "null"
break
case env.BUILD_CAUSE.contains('Started by timer'):
invokedBy = 'Timer'
pullRequest = "${GIT_REFERENCE}"
pullRequestTitle = "Null"
pullRequest = "null"
pullRequestTitle = "null"
gitReference = "${GIT_REFERENCE}"
pullRequestOwner = "null"
break
case "${pr_number}" == "Null":
case "${post_merge_action}" == "true":
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Same as above.
With this change https://github.com/opensearch-project/OpenSearch/pull/13786/files the pr_number is not null anymore. A new field post_merge_action with true/false is added to identify the push event.

invokedBy = 'Post Merge Action'
pullRequest = "${GIT_REFERENCE}"
pullRequest = "${pr_number}"
pullRequestTitle = "${pr_title}"
gitReference = "${pr_from_sha}"
pullRequestOwner = "${pr_owner}"
break
default:
invokedBy = 'Pull Request'
pullRequest = "${pr_number}"
pullRequestTitle = "${pr_title}"
gitReference = "${pr_from_sha}"
pullRequestOwner = "${pr_owner}"
}
publishGradleCheckTestResults(prNumber: "${pullRequest}" , prDescription: "${pullRequestTitle}", invokeType: "${invokedBy}")
publishGradleCheckTestResults(prNumber: "${pullRequest}" , prTitle: "${pullRequestTitle}", prOwner: "${pullRequestOwner}", invokeType: "${invokedBy}", gitReference: "${gitReference}")
prudhvigodithi marked this conversation as resolved.
Show resolved Hide resolved
sh("rm -rf *")
postCleanup()
}
Expand Down
Loading