Skip to content

Commit 9fd32d6

Browse files
committed
ci: improve functional review requirement integration
1 parent 28f207e commit 9fd32d6

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

Jenkinsfile

+26-3
Original file line numberDiff line numberDiff line change
@@ -500,11 +500,17 @@ pipeline {
500500
return
501501
}
502502

503+
if (!env.CHANGE_ID) {
504+
echo "Not a Pull request."
505+
return
506+
}
507+
503508
def issue = jiraGetIssue site: 'irontec.atlassian.net', idOrKey: env.JIRA_TICKET
504509

505510
// Functional Reviewer - 10105
506511
if (issue.data.fields.customfield_10105) {
507512
println "Functional Reviewer: ${issue.data.fields.customfield_10105.displayName}"
513+
pullRequest.addLabel('functional-review')
508514
} else {
509515
println "No functional reviewer assigned."
510516
}
@@ -518,9 +524,26 @@ pipeline {
518524
def status = issue.data.fields.status
519525
println "Issue Status: ${status.name} (${status.id})"
520526

521-
// For Issues with Functional reviewer and not validated
522-
if (issue.data.fields.customfield_10105 && status.id != "10325") {
523-
unstable "Functional approval required."
527+
// For Issues with Functional reviewer
528+
if (issue.data.fields.customfield_10105) {
529+
// Not validated
530+
if (status.id != "10325") {
531+
// Ensure the PR is not already marked as changed requested
532+
def lastFuncReviewStatus
533+
for (review in pullRequest.reviews) {
534+
if (review.user == "ironArt3mis") {
535+
lastFuncReviewStatus = review.state
536+
}
537+
}
538+
// PR already marked as review requested
539+
if (lastFuncReviewStatus == "CHANGES_REQUESTED") {
540+
echo "This PR is already marked as functional review required"
541+
return
542+
}
543+
pullRequest.review('REQUEST_CHANGES', 'Functional review required')
544+
} else {
545+
pullRequest.review('APPROVE')
546+
}
524547
}
525548
}
526549
}

0 commit comments

Comments
 (0)