From 9fd32d65b00b6f3c6478447da54e1d5e0b9f7e09 Mon Sep 17 00:00:00 2001 From: Kaian Date: Wed, 15 May 2024 09:41:51 +0200 Subject: [PATCH] ci: improve functional review requirement integration --- Jenkinsfile | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index f38daf9a9ed..9ad179d6378 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -500,11 +500,17 @@ pipeline { return } + if (!env.CHANGE_ID) { + echo "Not a Pull request." + return + } + def issue = jiraGetIssue site: 'irontec.atlassian.net', idOrKey: env.JIRA_TICKET // Functional Reviewer - 10105 if (issue.data.fields.customfield_10105) { println "Functional Reviewer: ${issue.data.fields.customfield_10105.displayName}" + pullRequest.addLabel('functional-review') } else { println "No functional reviewer assigned." } @@ -518,9 +524,26 @@ pipeline { def status = issue.data.fields.status println "Issue Status: ${status.name} (${status.id})" - // For Issues with Functional reviewer and not validated - if (issue.data.fields.customfield_10105 && status.id != "10325") { - unstable "Functional approval required." + // For Issues with Functional reviewer + if (issue.data.fields.customfield_10105) { + // Not validated + if (status.id != "10325") { + // Ensure the PR is not already marked as changed requested + def lastFuncReviewStatus + for (review in pullRequest.reviews) { + if (review.user == "ironArt3mis") { + lastFuncReviewStatus = review.state + } + } + // PR already marked as review requested + if (lastFuncReviewStatus == "CHANGES_REQUESTED") { + echo "This PR is already marked as functional review required" + return + } + pullRequest.review('REQUEST_CHANGES', 'Functional review required') + } else { + pullRequest.review('APPROVE') + } } } }